stanley-king 3 years ago
parent
commit
1ce51a5528
1 changed files with 5 additions and 11 deletions
  1. 5 11
      helper/queue/iqueue.php

+ 5 - 11
helper/queue/iqueue.php

@@ -13,18 +13,16 @@ class IQueueDB
 {
     private $_redis;
 
-    private $_tb_prefix;
+    private $_queue_name;
     //存定义存储表的数量,系统会随机分配存储
 
-    private $_tb_num = 3;
     private $_comode;
-
     public function __construct($queue_name,$comode = false)
     {
         if ( !extension_loaded('redis') ) {
             throw_exception('redis failed to load');
         }
-        $this->_tb_prefix = $queue_name;
+        $this->_queue_name = $queue_name;
         $this->_comode = $comode;
 
         if ($this->_comode) {
@@ -72,7 +70,7 @@ class IQueueDB
     public function rpush($value)
     {
         try {
-            return $this->_redis->rPush($this->_tb_prefix . rand(1, $this->_tb_num), $value);
+            return $this->_redis->rPush($this->_queue_name, $value);
         } catch(Exception $e) {
             throw_exception($e->getMessage());
         }
@@ -81,7 +79,7 @@ class IQueueDB
     public function lpush($value)
     {
         try {
-            return $this->_redis->lPush($this->_tb_prefix.rand(1,$this->_tb_num),$value);
+            return $this->_redis->lPush($this->_queue_name,$value);
         } catch(Exception $e) {
             throw_exception($e->getMessage());
         }
@@ -89,10 +87,7 @@ class IQueueDB
 
     public function scan()
     {
-        $list_key = [];
-        for ($i = 1; $i <= $this->_tb_num; $i++) {
-            $list_key[] = $this->_tb_prefix . $i;
-        }
+        $list_key[] = $this->_queue_name;
         return $list_key;
     }
 
@@ -119,7 +114,6 @@ class IQueueDB
         $this->_redis->flushAll();
     }
 }
-
 /**
  * 队列处理
  *