Skip to content

Commit 867d88e

Browse files
ikari7789andrew-miller-rakuten
authored andcommitted
Allow overriding prefix via constructor
Initialize the prefix as part of the constructor and allow it to be set via the options. Eases ability to set a custom prefix as most users are not likely interacting with the Redis object directly, but rather sending in an options array via a higher-level loader.
1 parent b0931c7 commit 867d88e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Prometheus/Storage/Redis.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ class Redis implements Adapter
2525
'read_timeout' => '10',
2626
'persistent_connections' => false,
2727
'password' => null,
28+
'prefix' => 'PROMETHEUS_',
2829
];
2930

3031
/**
3132
* @var string
3233
*/
33-
private static $prefix = 'PROMETHEUS_';
34+
private static $prefix;
3435

3536
/**
3637
* @var array
@@ -54,6 +55,7 @@ class Redis implements Adapter
5455
public function __construct(array $options = [])
5556
{
5657
$this->options = array_merge(self::$defaultOptions, $options);
58+
static::setPrefix($this->options['prefix']);
5759
$this->redis = new \Redis();
5860
}
5961

0 commit comments

Comments
 (0)