From fb722b6eacc574975de223a05e619f9c90aa8d99 Mon Sep 17 00:00:00 2001 From: Masterklavi Date: Sat, 12 Mar 2016 17:32:12 +0500 Subject: Added the expiration to save() method --- system/libraries/Cache/drivers/Cache_redis.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'system/libraries/Cache') diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 6da86728c..fa318403e 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -184,12 +184,19 @@ class CI_Cache_redis extends CI_Driver { if (is_array($data) OR is_object($data)) { - return $this->_redis->hMSet($id, array('type' => gettype($data), 'data' => serialize($data))); + $success = $this->_redis->hMSet($id, array('type' => gettype($data), 'data' => serialize($data))); } else { - return $this->_redis->hMSet($id, array('type' => gettype($data), 'data' => $data)); + $success = $this->_redis->hMSet($id, array('type' => gettype($data), 'data' => $data)); } + + if ($success && $ttl) + { + $this->_redis->expireAt($id, time() + $ttl); + } + + return $success; } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b