File tree Expand file tree Collapse file tree 3 files changed +9
-0
lines changed
Expand file tree Collapse file tree 3 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public function __construct(array $config)
2626 'reserved ' => null ,
2727 'retry_interval ' => null ,
2828 'persisted ' => false ,
29+ 'database ' => 0 ,
2930 ], $ config );
3031 }
3132
@@ -80,6 +81,8 @@ public function connect()
8081 $ this ->config ['retry_interval ' ]
8182 );
8283 }
84+
85+ $ this ->redis ->select ($ this ->config ['database ' ]);
8386 }
8487
8588 return $ this ->redis ;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class RedisConnectionFactory implements PsrConnectionFactory
2727 * 'vendor' => 'The library used internally to interact with Redis server
2828 * 'persisted' => bool, Whether it use single persisted connection or open a new one for every context
2929 * 'lazy' => the connection will be performed as later as possible, if the option set to true
30+ * 'database' => Database index to select when connected (default value: 0)
3031 * ].
3132 *
3233 * or
@@ -139,6 +140,7 @@ private function defaultConfig()
139140 'vendor ' => 'phpredis ' ,
140141 'persisted ' => false ,
141142 'lazy ' => true ,
143+ 'database ' => 0 ,
142144 ];
143145 }
144146}
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ public function addConfiguration(ArrayNodeDefinition $builder)
5454 ->defaultTrue ()
5555 ->info ('the connection will be performed as later as possible, if the option set to true ' )
5656 ->end ()
57+ ->integerNode ('database ' )
58+ ->defaultValue (0 )
59+ ->info ('Database index to select when connected. ' )
60+ ->end ()
5761 ;
5862 }
5963
You can’t perform that action at this time.
0 commit comments