@@ -25,6 +25,7 @@ class RedisConnectionFactory implements PsrConnectionFactory
2525 * 'reserved' => should be null if $retry_interval is specified
2626 * 'retry_interval' => retry interval in milliseconds.
2727 * 'vendor' => 'The library used internally to interact with Redis server
28+ * 'redis' => 'Used only if vendor is custom, should contain an instance of \Enqueue\Redis\Redis interface.
2829 * 'persisted' => bool, Whether it use single persisted connection or open a new one for every context
2930 * 'lazy' => the connection will be performed as later as possible, if the option set to true
3031 * 'database' => Database index to select when connected (default value: 0)
@@ -50,7 +51,7 @@ public function __construct($config = 'redis:')
5051
5152 $ this ->config = array_replace ($ this ->defaultConfig (), $ config );
5253
53- $ supportedVendors = ['predis ' , 'phpredis ' ];
54+ $ supportedVendors = ['predis ' , 'phpredis ' , ' custom ' ];
5455 if (false == in_array ($ this ->config ['vendor ' ], $ supportedVendors , true )) {
5556 throw new \LogicException (sprintf (
5657 'Unsupported redis vendor given. It must be either "%s". Got "%s" ' ,
@@ -90,6 +91,18 @@ private function createRedis()
9091 $ this ->redis = new PRedis (new Client ($ this ->config , ['exceptions ' => true ]));
9192 }
9293
94+ if ('custom ' == $ this ->config ['vendor ' ] && false == $ this ->redis ) {
95+ if (empty ($ this ->config ['redis ' ])) {
96+ throw new \LogicException ('The redis option should be set if vendor is custom. ' );
97+ }
98+
99+ if (false == $ this ->config ['redis ' ] instanceof Redis) {
100+ throw new \LogicException (sprintf ('The redis option should be instance of "%s". ' , Redis::class));
101+ }
102+
103+ $ this ->redis = $ this ->config ['redis ' ];
104+ }
105+
93106 $ this ->redis ->connect ();
94107 }
95108
@@ -138,6 +151,7 @@ private function defaultConfig()
138151 'reserved ' => null ,
139152 'retry_interval ' => null ,
140153 'vendor ' => 'phpredis ' ,
154+ 'redis ' => null ,
141155 'persisted ' => false ,
142156 'lazy ' => true ,
143157 'database ' => 0 ,
0 commit comments