Update Redis.php

This commit is contained in:
黄朝晖 2020-07-07 17:15:14 +08:00 committed by GitHub
parent 5c137bcd79
commit fdc59578a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,9 +62,6 @@ class Redis implements Adapter
*/ */
private $connectionInitialized = false; private $connectionInitialized = false;
/**
* Redis constructor.
*/
public function __construct(array $options = []) public function __construct(array $options = [])
{ {
$this->options = array_merge(self::$defaultOptions, $options); $this->options = array_merge(self::$defaultOptions, $options);
@ -74,7 +71,6 @@ class Redis implements Adapter
/** /**
* Create an instance from an established redis connection. * Create an instance from an established redis connection.
* @param \Hyperf\Redis\Redis|\Redis $redis * @param \Hyperf\Redis\Redis|\Redis $redis
* @return Redis
*/ */
public static function fromExistingConnection($redis): self public static function fromExistingConnection($redis): self
{ {
@ -409,14 +405,9 @@ LUA
return implode(':', [self::$prefix, $data['type'], $data['name']]); return implode(':', [self::$prefix, $data['type'], $data['name']]);
} }
/** protected function getRedisTag(string $metricType): string
* Adapt redis cluster get tag
*
*/
protected function getRedisTag($metricType): string
{ {
switch($metricType) switch($metricType) {
{
case Counter::TYPE: case Counter::TYPE:
return "{counter}"; return "{counter}";
case Histogram::TYPE: case Histogram::TYPE:
@ -435,8 +426,7 @@ LUA
*/ */
private function getMetricGatherKey($metricType): string private function getMetricGatherKey($metricType): string
{ {
switch($metricType) switch($metricType) {
{
case Counter::TYPE: case Counter::TYPE:
return self::$prefix . Counter::TYPE . self::PROMETHEUS_METRIC_KEYS_SUFFIX . $this->getRedisTag(Counter::TYPE); return self::$prefix . Counter::TYPE . self::PROMETHEUS_METRIC_KEYS_SUFFIX . $this->getRedisTag(Counter::TYPE);
case Histogram::TYPE: case Histogram::TYPE: