Skip to content

Commit cefe795

Browse files
committed
#98 新增支持 Redis 哨兵模式、集群模式 cache、lock、queue、rate-limit 改造兼容
1 parent 8602e0d commit cefe795

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/Driver/RedisQueueDriver.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,17 @@ protected function parseTimeoutMessages(int $count = 100)
630630
*/
631631
public function getMessageKeyPrefix(): string
632632
{
633-
return $this->prefix . $this->name . ':message:';
633+
$redis = RedisManager::getInstance($this->poolName);
634+
if ($redis->isCluster())
635+
{
636+
$name = '{' . $this->name . '}';
637+
}
638+
else
639+
{
640+
$name = $this->name;
641+
}
642+
643+
return $this->prefix . $name . ':message:';
634644
}
635645

636646
/**
@@ -640,7 +650,17 @@ public function getMessageKeyPrefix(): string
640650
*/
641651
public function getMessageIdKey(): string
642652
{
643-
return $this->prefix . $this->name . ':message:id';
653+
$redis = RedisManager::getInstance($this->poolName);
654+
if ($redis->isCluster())
655+
{
656+
$name = '{' . $this->name . '}';
657+
}
658+
else
659+
{
660+
$name = $this->name;
661+
}
662+
663+
return $this->prefix . $name . ':message:id';
644664
}
645665

646666
/**
@@ -652,6 +672,16 @@ public function getMessageIdKey(): string
652672
*/
653673
public function getQueueKey(int $queueType): string
654674
{
655-
return $this->prefix . $this->name . ':' . strtolower(QueueType::getName($queueType));
675+
$redis = RedisManager::getInstance($this->poolName);
676+
if ($redis->isCluster())
677+
{
678+
$name = '{' . $this->name . '}';
679+
}
680+
else
681+
{
682+
$name = $this->name;
683+
}
684+
685+
return $this->prefix . $name . ':' . strtolower(QueueType::getName($queueType));
656686
}
657687
}

0 commit comments

Comments
 (0)