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

Commit

Permalink
Support database selection
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rdohms committed Oct 14, 2018
1 parent 01c8937 commit c27fae8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ private function openConnection()
if ($this->options['password']) {
$this->redis->auth($this->options['password']);
}
if (isset($this->options['database'])) {
$this->redis->select($this->options['database']);
}

$this->redis->setOption(\Redis::OPT_READ_TIMEOUT, $this->options['read_timeout']);

} catch (\RedisException $e) {
throw new StorageException("Can't connect to Redis server", 0, $e);
}
Expand Down

0 comments on commit c27fae8

Please sign in to comment.