diff options
author | Masterklavi <masterklavi@gmail.com> | 2016-03-12 08:51:46 +0100 |
---|---|---|
committer | Masterklavi <masterklavi@gmail.com> | 2016-03-12 08:51:46 +0100 |
commit | 12c3d1474e43cdd6e76245e89f11440793a5d8f0 (patch) | |
tree | 18eb1ec992112e36a0aa0bdfa2018c70e9d0a12d /system | |
parent | 25da4ec2e02d7ec258f11916d1b9b40c10b97ace (diff) |
Setup the data defining for stored data
Diffstat (limited to 'system')
-rw-r--r-- | system/libraries/Cache/drivers/Cache_redis.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index a302609a2..c334afb0d 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -143,19 +143,20 @@ class CI_Cache_redis extends CI_Driver */ public function get($key) { - $value = $this->_redis->hMGet($key, array('serialized', 'data')); + $value = $this->_redis->hMGet($key, array('type', 'data')); - if ( ! is_array($value) OR ! isset($value['serialized'], $value['data'])) + if ( ! is_array($value) OR ! isset($value['type'], $value['data'])) { return FALSE; } - if ($value['serialized']) + if ($value['type'] === 'array' OR $value['type'] === 'object') { return unserialize($value['data']); } else { + settype($value['data'], $value['type']); return $value['data']; } } @@ -175,11 +176,11 @@ class CI_Cache_redis extends CI_Driver { if (is_array($data) OR is_object($data)) { - return $this->_redis->hMSet($id, array('serialized' => TRUE, 'data' => serialize($data))); + return $this->_redis->hMSet($id, array('type' => gettype($data), 'data' => serialize($data))); } else { - return $this->_redis->hMSet($id, array('serialized' => FALSE, 'data' => $data)); + return $this->_redis->hMSet($id, array('type' => gettype($data), 'data' => $data)); } } |