瀏覽代碼

Update:redis过期方法 和 mysql set方法

Jinhui Zhu 4 年之前
父節點
當前提交
94131d6961
共有 2 個文件被更改,包括 6 次插入3 次删除
  1. 4 2
      src/Cache/Redis.php
  2. 2 1
      src/Driver/Base.php

+ 4 - 2
src/Cache/Redis.php

@@ -59,7 +59,8 @@ class Redis implements Intf
         try {
             $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']);
+                //$this->redis->setTimeout($id, $this->policy['life_time']);
+                $this->redis->expire($id, $this->policy['life_time']);
             }
         } catch (\CredisException $e) {
             throw new \Qii\Exceptions\Errors(\Qii::i(-1, $e->getMessage()), __LINE__);
@@ -79,7 +80,8 @@ class Redis implements Intf
         try {
             $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']);
+                //$this->redis->setTimeout($id, $this->policy['life_time']);
+                $this->redis->expire($id, $this->policy['life_time']);
             }
         } catch (\CredisException $e) {
             throw new \Qii\Exceptions\Errors(\Qii::i(-1, $e->getMessage()), __LINE__);

+ 2 - 1
src/Driver/Base.php

@@ -345,6 +345,7 @@ class Base
         $operator = array("equal" => "%s`%s` = '%s'", "plus" => "%s`%s` = %s`%s`+%s", "minus" => "%s`%s` = %s`%s`-%s", "multiply" => "%s`%s` = %s`%s`*%s", "divide" => "%s`%s` = %s`%s`/%s");
         foreach($set as $key => $val)
         {
+            $val = $this->setQuote($val);
             $alias = $this->getFieldAlias($key);
             $operate = $this->getFieldOperator($alias['name']);
             if($operate['operator'] == '') {
@@ -355,8 +356,8 @@ class Base
             }else{
                 $this->sets[] = sprintf($operator[$operate['operator']], $alias['alias'], $operate['field'], $alias['alias'], $operate['field'], $val);
             }
-
         }
+
         return $this;
     }