wesmiler vor 6 Jahren
Ursprung
Commit
05ad1f2009

+ 1 - 8
app/index/service/RedisService.php

@@ -77,14 +77,7 @@ class RedisService
      * @return bool
      */
     public static function delByKeys($key){
-        $keys = self::instance()->keys($key);
-        if(empty($keys)){
-            return false;
-        }
-
-        foreach($keys as $key){
-            self::instance()->rm($key);
-        }
+        return self::instance()->rms($key);
     }
 
     /**

+ 16 - 0
vendor/thinkphp/library/think/cache/driver/Redis.php

@@ -195,6 +195,22 @@ class Redis extends Driver
     }
 
     /**
+     * 批量删除缓存
+     * @access public
+     * @param  string $name 缓存变量名
+     * @return boolean
+     */
+    public function rms($name)
+    {
+        if(strpos($name, '*') !== false){
+            $key = $this->handler->keys($this->getCacheKey($name));
+        }else{
+            $key = $this->getCacheKey($name);
+        }
+        return $this->handler->delete($key);
+    }
+
+    /**
      * 清除缓存
      * @access public
      * @param  string $tag 标签名