This repository was archived by the owner on Oct 22, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ Change the Redis options (the example shows the defaults):
6666 [
6767 'host' => '127.0.0.1',
6868 'port' => 6379,
69+ 'password' => null,
6970 'timeout' => 0.1, // in seconds
7071 'read_timeout' => 10, // in seconds
7172 'persistent_connections' => false
Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ public function __construct(array $options = array())
3838 if (!isset (self ::$ defaultOptions ['persistent_connections ' ])) {
3939 self ::$ defaultOptions ['persistent_connections ' ] = false ;
4040 }
41+ if (!isset (self ::$ defaultOptions ['password ' ])) {
42+ self ::$ defaultOptions ['password ' ] = null ;
43+ }
4144
4245 $ this ->options = array_merge (self ::$ defaultOptions , $ options );
4346 $ this ->redis = new \Redis ();
@@ -91,6 +94,9 @@ private function openConnection()
9194 } else {
9295 @$ this ->redis ->connect ($ this ->options ['host ' ], $ this ->options ['port ' ], $ this ->options ['timeout ' ]);
9396 }
97+ if ($ this ->options ['password ' ]) {
98+ $ this ->redis ->auth ($ this ->options ['password ' ]);
99+ }
94100 $ this ->redis ->setOption (\Redis::OPT_READ_TIMEOUT , $ this ->options ['read_timeout ' ]);
95101 } catch (\RedisException $ e ) {
96102 throw new StorageException ("Can't connect to Redis server " , 0 , $ e );
You can’t perform that action at this time.
0 commit comments