diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index f38391b..ca2daf5 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -41,6 +41,9 @@ public function __construct(array $options = array()) if (!isset(self::$defaultOptions['password'])) { self::$defaultOptions['password'] = null; } + if (!isset(self::$defaultOptions['db'])) { + self::$defaultOptions['db'] = false; + } $this->options = array_merge(self::$defaultOptions, $options); $this->redis = new \Redis(); @@ -97,6 +100,9 @@ private function openConnection() if ($this->options['password']) { $this->redis->auth($this->options['password']); } + if($this->options['db']){ + $this->redis->select($this->options['db']); + } $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);