Pārlūkot izejas kodu

redis 操作增加返回值

Jinhui Zhu 5 gadi atpakaļ
vecāks
revīzija
b7bf9af5d6
1 mainītis faili ar 7 papildinājumiem un 2 dzēšanām
  1. 7 2
      src/Cache/Redis.php

+ 7 - 2
src/Cache/Redis.php

@@ -52,17 +52,19 @@ class Redis implements Intf
      */
     public function hMset($id, $data, array $policy = null)
     {
+        $res = false;
         if (is_array($policy)) {
             $this->policy = array_merge($this->policy, $policy);
         }
         try {
-            $this->redis->hMset($id, $data);
+            $res = $this->redis->hMset($id, $data);
             if (isset($this->policy['life_time']) && $this->policy['life_time'] > 0) {
                 $this->redis->setTimeout($id, $this->policy['life_time']);
             }
         } catch (\CredisException $e) {
             throw new \Qii\Exceptions\Errors(\Qii::i(-1, $e->getMessage()), __LINE__);
         }
+        return $res;
     }
 
     /**
@@ -70,17 +72,20 @@ class Redis implements Intf
      */
     public function set($id, $value, array $policy = null)
     {
+        $res = false;
         if (is_array($policy)) {
             $this->policy = array_merge($this->policy, $policy);
         }
         try {
-            $this->redis->set($id, $value);
+            $res = $this->redis->set($id, $value);
             if (isset($this->policy['life_time']) && $this->policy['life_time'] > 0) {
                 $this->redis->setTimeout($id, $this->policy['life_time']);
             }
         } catch (\CredisException $e) {
             throw new \Qii\Exceptions\Errors(\Qii::i(-1, $e->getMessage()), __LINE__);
         }
+
+        return $res;
     }
     /**
      * 获取指定key的数据