Skip to content

Commit

Permalink
Allow overriding prefix via constructor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ikari7789 authored and andrew-miller-rakuten committed Mar 13, 2020
1 parent b0931c7 commit 867d88e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ class Redis implements Adapter
'read_timeout' => '10',
'persistent_connections' => false,
'password' => null,
'prefix' => 'PROMETHEUS_',
];

/**
* @var string
*/
private static $prefix = 'PROMETHEUS_';
private static $prefix;

/**
* @var array
Expand All @@ -54,6 +55,7 @@ class Redis implements Adapter
public function __construct(array $options = [])
{
$this->options = array_merge(self::$defaultOptions, $options);
static::setPrefix($this->options['prefix']);
$this->redis = new \Redis();
}

Expand Down

0 comments on commit 867d88e

Please sign in to comment.