Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

Commit c27fae8

Browse files
committed
Support database selection
In order to allow the use of different databases in Redis, the connection now supports switching to a new database. One important factor to understand here is that if you are using `pconnect` and you do a `select` operation, you may be changing the same connection the rest of your code is using.
1 parent 01c8937 commit c27fae8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Prometheus/Storage/Redis.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ private function openConnection()
9797
if ($this->options['password']) {
9898
$this->redis->auth($this->options['password']);
9999
}
100+
if (isset($this->options['database'])) {
101+
$this->redis->select($this->options['database']);
102+
}
103+
100104
$this->redis->setOption(\Redis::OPT_READ_TIMEOUT, $this->options['read_timeout']);
105+
101106
} catch (\RedisException $e) {
102107
throw new StorageException("Can't connect to Redis server", 0, $e);
103108
}

0 commit comments

Comments
 (0)