diff --git a/src/RSMQ.php b/src/RSMQ.php index 5f7d180..8239633 100644 --- a/src/RSMQ.php +++ b/src/RSMQ.php @@ -442,4 +442,25 @@ public function validate(array $params): void throw new Exception(sprintf($message, self::MIN_MESSAGE_SIZE, self::MAX_PAYLOAD_SIZE)); } } + /** + * @var $queue name + * This was created to check if queue exist before creating another queue. + * This functions helps developers to first check if a queue already exist or not before creating a new one. + */ + public function queueExist(string $name): bool + { + $this->validate([ + 'queue' => $name, + ]); + + $transaction = $this->redis->multi(); + $transaction->hmget("{$this->ns}$name:Q", ['vt', 'delay', 'maxsize']); + $transaction->time(); + $resp = $transaction->exec(); + if($resp[0]['vt'] === false){ + return false; + } + //Create Queue + return true; + } }