|
@@ -26,8 +26,7 @@ require __DIR__ . '/Predis/Autoloader.php';
|
|
|
* 1.0.0 pguan,基础功能, 方法与memcache看齐. <br/>
|
|
|
*/
|
|
|
class CRedisUtil extends CMemBase {
|
|
|
-
|
|
|
- public $keyDic = null;
|
|
|
+// public $keyDic = null;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -171,7 +170,7 @@ class CRedisUtil extends CMemBase {
|
|
|
'port' => $port,
|
|
|
'password' => $pwd,
|
|
|
));
|
|
|
- $this->keyDic = new \stdClass();
|
|
|
+// $this->keyDic = new \stdClass();
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
@@ -193,7 +192,7 @@ class CRedisUtil extends CMemBase {
|
|
|
if (!$result || $result == "" || $result == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- $this->keyDic->$key = $result;
|
|
|
+// $this->keyDic->$key = $result;
|
|
|
return JsonUtil::decode($result);
|
|
|
}
|
|
|
|
|
@@ -226,35 +225,35 @@ class CRedisUtil extends CMemBase {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 安全的写入操作
|
|
|
- * @deprecated since version 1.0 云平台暂时不支持
|
|
|
- * @param string $key
|
|
|
- * @param any $value
|
|
|
- * @return boolean 成功true,失败false
|
|
|
- */
|
|
|
- public function cas($key, $value, $ts = 0) {
|
|
|
- if (false) { # ps. 各云平台皆不支持eval方法执行lua脚本.等开放支持的时候才是真正支持cas的时候
|
|
|
- $castoken = $this->keyDic->$key;
|
|
|
-# # 定义一段脚本
|
|
|
- $script = <<<casscript
|
|
|
-if redis.call("get",KEYS[1]) == "$castoken"
|
|
|
-then
|
|
|
- return redis.call("set",KEYS[1],ARGV[1])
|
|
|
-else
|
|
|
- return 0
|
|
|
-end
|
|
|
-casscript;
|
|
|
- $ret = $this->redis->eval($script, 1, $key, $value); # redis 执行lua脚本
|
|
|
- if (0 == $ret) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // 非线程安全,原因见下
|
|
|
- return $this->set($key, $value, $ts);
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 安全的写入操作
|
|
|
+// * @deprecated since version 1.0 云平台暂时不支持
|
|
|
+// * @param string $key
|
|
|
+// * @param any $value
|
|
|
+// * @return boolean 成功true,失败false
|
|
|
+// */
|
|
|
+// public function cas($key, $value, $ts = 0) {
|
|
|
+// if (false) { # ps. 各云平台皆不支持eval方法执行lua脚本.等开放支持的时候才是真正支持cas的时候
|
|
|
+// $castoken = $this->keyDic->$key;
|
|
|
+//# # 定义一段脚本
|
|
|
+// $script = <<<casscript
|
|
|
+//if redis.call("get",KEYS[1]) == "$castoken"
|
|
|
+//then
|
|
|
+// return redis.call("set",KEYS[1],ARGV[1])
|
|
|
+//else
|
|
|
+// return 0
|
|
|
+//end
|
|
|
+//casscript;
|
|
|
+// $ret = $this->redis->eval($script, 1, $key, $value); # redis 执行lua脚本
|
|
|
+// if (0 == $ret) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 非线程安全,原因见下
|
|
|
+// return $this->set($key, $value, $ts);
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 删除一个或多个指定键值
|