| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,18 @@ public function __construct(array $config) | |||
| 34 | 34 | throw new \LogicException('The package "predis/predis" must be installed. Please run "composer req predis/predis:^1.1" to install it'); | |
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | + if (null !== $config['client']) { | ||
| 38 | + if (!$config['client'] instanceof Client) { | ||
| 39 | + throw new \InvalidArgumentException(sprintf('%s configuration property is expected to be an instance of %s class. %s was passed instead.', 'client', Client::class, gettype($config['client']))); | ||
| 40 | + } | ||
| 41 | + $this->redis = $config['client']; | ||
| 42 | + | ||
| 43 | + $this->options = []; | ||
| 44 | + $this->parameters = []; | ||
| 45 | + | ||
| 46 | + return; | ||
| 47 | + } | ||
| 48 | + | ||
| 37 | 49 | $this->options = $config['predis_options']; | |
| 38 | 50 | ||
| 39 | 51 | $this->parameters = [ | |
@@ -54,6 +66,11 @@ public function __construct(array $config) | |||
| 54 | 66 | } | |
| 55 | 67 | } | |
| 56 | 68 | ||
| 69 | + public static function createWithClient(Client $client): self | ||
| 70 | + { | ||
| 71 | + return new self(['client' => $client]); | ||
| 72 | + } | ||
| 73 | + | ||
| 57 | 74 | public function eval(string $script, array $keys = [], array $args = []) | |
| 58 | 75 | { | |
| 59 | 76 | try { | |
@@ -140,3 +157,4 @@ public function del(string $key): void | |||
| 140 | 157 | $this->redis->del([$key]); | |
| 141 | 158 | } | |
| 142 | 159 | } | |
| 160 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments