mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 16:12:49 +08:00
Redis缓存驱动改用serialize序列化替代json序列化
This commit is contained in:
10
library/think/cache/driver/Redis.php
vendored
10
library/think/cache/driver/Redis.php
vendored
@@ -83,9 +83,8 @@ class Redis extends Driver
|
|||||||
if (is_null($value) || false === $value) {
|
if (is_null($value) || false === $value) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
$jsonData = json_decode($value, true);
|
|
||||||
// 检测是否为JSON数据 true 返回JSON解析数组, false返回源数据 byron sampson<xiaobo.sun@qq.com>
|
return unserialize($value);
|
||||||
return (null === $jsonData) ? $value : $jsonData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,9 +106,8 @@ class Redis extends Driver
|
|||||||
if ($this->tag && !$this->has($name)) {
|
if ($this->tag && !$this->has($name)) {
|
||||||
$first = true;
|
$first = true;
|
||||||
}
|
}
|
||||||
$key = $this->getCacheKey($name);
|
$key = $this->getCacheKey($name);
|
||||||
//对数组/对象数据进行缓存处理,保证数据完整性 byron sampson<xiaobo.sun@qq.com>
|
$value = serialize($value);
|
||||||
$value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
|
|
||||||
if (is_int($expire) && $expire) {
|
if (is_int($expire) && $expire) {
|
||||||
$result = $this->handler->setex($key, $expire, $value);
|
$result = $this->handler->setex($key, $expire, $value);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user