Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame] | 1 | <?php |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Anton Lindqvist | 5ccf5ce | 2012-06-08 11:47:17 +0200 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 6 | * |
Anton Lindqvist | 5a1d953 | 2012-01-23 23:20:26 +0100 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
| 8 | * |
| 9 | * Licensed under the Open Software License version 3.0 |
| 10 | * |
| 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
| 18 | * |
| 19 | * @package CodeIgniter |
| 20 | * @author EllisLab Dev Team |
darwinel | 871754a | 2014-02-11 17:34:57 +0100 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) |
Anton Lindqvist | 5a1d953 | 2012-01-23 23:20:26 +0100 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
| 23 | * @link http://codeigniter.com |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 24 | * @since Version 3.0 |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 25 | * @filesource |
| 26 | */ |
Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame] | 27 | defined('BASEPATH') OR exit('No direct script access allowed'); |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 28 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 29 | /** |
| 30 | * CodeIgniter Redis Caching Class |
| 31 | * |
| 32 | * @package CodeIgniter |
| 33 | * @subpackage Libraries |
| 34 | * @category Core |
| 35 | * @author Anton Lindqvist <anton@qvister.se> |
| 36 | * @link |
| 37 | */ |
| 38 | class CI_Cache_redis extends CI_Driver |
| 39 | { |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 40 | /** |
| 41 | * Default config |
| 42 | * |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 43 | * @static |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 44 | * @var array |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 45 | */ |
Anton Lindqvist | 3573af8 | 2012-01-21 20:33:12 +0100 | [diff] [blame] | 46 | protected static $_default_config = array( |
Kakysha | 80d663a | 2013-10-28 01:39:17 +0400 | [diff] [blame] | 47 | 'socket_type' => 'tcp', |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 48 | 'host' => '127.0.0.1', |
Anton Lindqvist | 5ccf5ce | 2012-06-08 11:47:17 +0200 | [diff] [blame] | 49 | 'password' => NULL, |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 50 | 'port' => 6379, |
| 51 | 'timeout' => 0 |
| 52 | ); |
| 53 | |
| 54 | /** |
| 55 | * Redis connection |
| 56 | * |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 57 | * @var Redis |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 58 | */ |
Anton Lindqvist | 3573af8 | 2012-01-21 20:33:12 +0100 | [diff] [blame] | 59 | protected $_redis; |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 60 | |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 61 | /** |
| 62 | * An internal cache for storing keys of serialized values. |
| 63 | * |
| 64 | * @var array |
| 65 | */ |
| 66 | protected $_serialized; |
| 67 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 68 | // ------------------------------------------------------------------------ |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * Get cache |
| 72 | * |
Andrey Andreev | 43d7fa7 | 2014-01-09 17:29:45 +0200 | [diff] [blame] | 73 | * @param string Cache ID |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 74 | * @return mixed |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 75 | */ |
| 76 | public function get($key) |
| 77 | { |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 78 | $value = $this->_redis->get($key); |
| 79 | |
Ivan Tcholakov | e838c83 | 2014-08-18 09:56:05 +0300 | [diff] [blame] | 80 | if ($value !== FALSE && in_array($key, $this->_serialized, TRUE)) |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 81 | { |
| 82 | return unserialize($value); |
| 83 | } |
| 84 | |
| 85 | return $value; |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 86 | } |
| 87 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 88 | // ------------------------------------------------------------------------ |
| 89 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 90 | /** |
| 91 | * Save cache |
| 92 | * |
Andrey Andreev | 43d7fa7 | 2014-01-09 17:29:45 +0200 | [diff] [blame] | 93 | * @param string $id Cache ID |
| 94 | * @param mixed $data Data to save |
| 95 | * @param int $ttl Time to live in seconds |
| 96 | * @param bool $raw Whether to store the raw value (unused) |
| 97 | * @return bool TRUE on success, FALSE on failure |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 98 | */ |
Andrey Andreev | 43d7fa7 | 2014-01-09 17:29:45 +0200 | [diff] [blame] | 99 | public function save($id, $data, $ttl = 60, $raw = FALSE) |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 100 | { |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 101 | if (is_array($data) OR is_object($data)) |
| 102 | { |
| 103 | $data = serialize($data); |
| 104 | |
Ivan Tcholakov | c773a48 | 2014-08-18 10:02:49 +0300 | [diff] [blame] | 105 | if (($index_key = array_search($id, $this->_serialized, TRUE)) === FALSE) |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 106 | { |
| 107 | $this->_serialized[] = $id; |
| 108 | } |
| 109 | |
Ivan Tcholakov | 7c83557 | 2014-08-18 10:37:29 +0300 | [diff] [blame] | 110 | $this->_redis->sAdd('_ci_redis_serialized', $id); |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 111 | } |
| 112 | else |
| 113 | { |
Ivan Tcholakov | c773a48 | 2014-08-18 10:02:49 +0300 | [diff] [blame] | 114 | if (($index_key = array_search($id, $this->_serialized, TRUE)) !== FALSE) |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 115 | { |
| 116 | unset($this->_serialized[$index_key]); |
| 117 | } |
| 118 | |
Ivan Tcholakov | 7c83557 | 2014-08-18 10:37:29 +0300 | [diff] [blame] | 119 | $this->_redis->sRemove('_ci_redis_serialized', $id); |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 120 | } |
| 121 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 122 | return ($ttl) |
Andrey Andreev | 43d7fa7 | 2014-01-09 17:29:45 +0200 | [diff] [blame] | 123 | ? $this->_redis->setex($id, $ttl, $data) |
| 124 | : $this->_redis->set($id, $data); |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 125 | } |
| 126 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 127 | // ------------------------------------------------------------------------ |
| 128 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 129 | /** |
| 130 | * Delete from cache |
| 131 | * |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 132 | * @param string Cache key |
| 133 | * @return bool |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 134 | */ |
| 135 | public function delete($key) |
| 136 | { |
Ivan Tcholakov | d514d5c | 2014-08-18 12:04:27 +0300 | [diff] [blame^] | 137 | if ($result = ($this->_redis->delete($key) === 1)) |
| 138 | { |
| 139 | // This is for not leaving garbage keys within the Redis auxilary set. |
| 140 | $this->_redis->sRemove('_ci_redis_serialized', $key); |
| 141 | } |
Ivan Tcholakov | bc41761 | 2014-08-18 11:11:39 +0300 | [diff] [blame] | 142 | |
Ivan Tcholakov | d514d5c | 2014-08-18 12:04:27 +0300 | [diff] [blame^] | 143 | return $result; |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 144 | } |
| 145 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 146 | // ------------------------------------------------------------------------ |
| 147 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 148 | /** |
Andrey Andreev | 43d7fa7 | 2014-01-09 17:29:45 +0200 | [diff] [blame] | 149 | * Increment a raw value |
| 150 | * |
| 151 | * @param string $id Cache ID |
| 152 | * @param int $offset Step/value to add |
| 153 | * @return mixed New value on success or FALSE on failure |
| 154 | */ |
| 155 | public function increment($id, $offset = 1) |
| 156 | { |
Andrey Andreev | 5f0799a | 2014-07-31 13:32:41 +0300 | [diff] [blame] | 157 | return $this->_redis->incr($id, $offset); |
Andrey Andreev | 43d7fa7 | 2014-01-09 17:29:45 +0200 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | // ------------------------------------------------------------------------ |
| 161 | |
| 162 | /** |
| 163 | * Decrement a raw value |
| 164 | * |
| 165 | * @param string $id Cache ID |
| 166 | * @param int $offset Step/value to reduce by |
| 167 | * @return mixed New value on success or FALSE on failure |
| 168 | */ |
| 169 | public function decrement($id, $offset = 1) |
| 170 | { |
Andrey Andreev | 5f0799a | 2014-07-31 13:32:41 +0300 | [diff] [blame] | 171 | return $this->_redis->decr($id, $offset); |
Andrey Andreev | 43d7fa7 | 2014-01-09 17:29:45 +0200 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | // ------------------------------------------------------------------------ |
| 175 | |
| 176 | /** |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 177 | * Clean cache |
| 178 | * |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 179 | * @return bool |
| 180 | * @see Redis::flushDB() |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 181 | */ |
| 182 | public function clean() |
| 183 | { |
| 184 | return $this->_redis->flushDB(); |
| 185 | } |
| 186 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 187 | // ------------------------------------------------------------------------ |
| 188 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 189 | /** |
| 190 | * Get cache driver info |
| 191 | * |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 192 | * @param string Not supported in Redis. |
| 193 | * Only included in order to offer a |
| 194 | * consistent cache API. |
| 195 | * @return array |
| 196 | * @see Redis::info() |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 197 | */ |
| 198 | public function cache_info($type = NULL) |
| 199 | { |
| 200 | return $this->_redis->info(); |
| 201 | } |
| 202 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 203 | // ------------------------------------------------------------------------ |
| 204 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 205 | /** |
| 206 | * Get cache metadata |
| 207 | * |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 208 | * @param string Cache key |
| 209 | * @return array |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 210 | */ |
| 211 | public function get_metadata($key) |
| 212 | { |
| 213 | $value = $this->get($key); |
| 214 | |
| 215 | if ($value) |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 216 | { |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 217 | return array( |
| 218 | 'expire' => time() + $this->_redis->ttl($key), |
| 219 | 'data' => $value |
| 220 | ); |
| 221 | } |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 222 | |
| 223 | return FALSE; |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 224 | } |
| 225 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 226 | // ------------------------------------------------------------------------ |
| 227 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 228 | /** |
| 229 | * Check if Redis driver is supported |
| 230 | * |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 231 | * @return bool |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 232 | */ |
| 233 | public function is_supported() |
| 234 | { |
| 235 | if (extension_loaded('redis')) |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 236 | { |
Kakysha | 2d14673 | 2013-10-28 20:20:24 +0400 | [diff] [blame] | 237 | return $this->_setup_redis(); |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 238 | } |
| 239 | else |
| 240 | { |
Tyler Brownell | d967f72 | 2013-07-29 19:06:52 -0400 | [diff] [blame] | 241 | log_message('debug', 'The Redis extension must be loaded to use Redis cache.'); |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 242 | return FALSE; |
| 243 | } |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 244 | } |
| 245 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 246 | // ------------------------------------------------------------------------ |
| 247 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 248 | /** |
| 249 | * Setup Redis config and connection |
| 250 | * |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 251 | * Loads Redis config file if present. Will halt execution |
| 252 | * if a Redis connection can't be established. |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 253 | * |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 254 | * @return bool |
| 255 | * @see Redis::connect() |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 256 | */ |
Anton Lindqvist | 5ccf5ce | 2012-06-08 11:47:17 +0200 | [diff] [blame] | 257 | protected function _setup_redis() |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 258 | { |
| 259 | $config = array(); |
| 260 | $CI =& get_instance(); |
| 261 | |
| 262 | if ($CI->config->load('redis', TRUE, TRUE)) |
Anton Lindqvist | 5ccf5ce | 2012-06-08 11:47:17 +0200 | [diff] [blame] | 263 | { |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 264 | $config += $CI->config->item('redis'); |
| 265 | } |
| 266 | |
| 267 | $config = array_merge(self::$_default_config, $config); |
| 268 | |
| 269 | $this->_redis = new Redis(); |
| 270 | |
| 271 | try |
| 272 | { |
Kakysha | 80d663a | 2013-10-28 01:39:17 +0400 | [diff] [blame] | 273 | if ($config['socket_type'] === 'unix') |
| 274 | { |
Kakysha | ffe2130 | 2013-10-28 21:30:05 +0400 | [diff] [blame] | 275 | $success = $this->_redis->connect($config['socket']); |
Kakysha | 8f3f1f9 | 2013-10-28 23:14:08 +0400 | [diff] [blame] | 276 | } |
| 277 | else // tcp socket |
Kakysha | 80d663a | 2013-10-28 01:39:17 +0400 | [diff] [blame] | 278 | { |
Kakysha | ffe2130 | 2013-10-28 21:30:05 +0400 | [diff] [blame] | 279 | $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']); |
Kakysha | 2d14673 | 2013-10-28 20:20:24 +0400 | [diff] [blame] | 280 | } |
Andrey Andreev | 119d8a7 | 2014-01-08 15:27:53 +0200 | [diff] [blame] | 281 | |
Kakysha | ffe2130 | 2013-10-28 21:30:05 +0400 | [diff] [blame] | 282 | if ( ! $success) |
Kakysha | 2d14673 | 2013-10-28 20:20:24 +0400 | [diff] [blame] | 283 | { |
Kakysha | 333b69b | 2013-10-29 03:49:56 +0400 | [diff] [blame] | 284 | log_message('debug', 'Cache: Redis connection refused. Check the config.'); |
Kakysha | 2d14673 | 2013-10-28 20:20:24 +0400 | [diff] [blame] | 285 | return FALSE; |
Kakysha | 80d663a | 2013-10-28 01:39:17 +0400 | [diff] [blame] | 286 | } |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 287 | } |
| 288 | catch (RedisException $e) |
| 289 | { |
Kakysha | 333b69b | 2013-10-29 03:49:56 +0400 | [diff] [blame] | 290 | log_message('debug', 'Cache: Redis connection refused ('.$e->getMessage().')'); |
Kakysha | 2d14673 | 2013-10-28 20:20:24 +0400 | [diff] [blame] | 291 | return FALSE; |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 292 | } |
Anton Lindqvist | 210e664 | 2012-04-23 10:13:46 +0200 | [diff] [blame] | 293 | |
Anton Lindqvist | 5ccf5ce | 2012-06-08 11:47:17 +0200 | [diff] [blame] | 294 | if (isset($config['password'])) |
| 295 | { |
Anton Lindqvist | 210e664 | 2012-04-23 10:13:46 +0200 | [diff] [blame] | 296 | $this->_redis->auth($config['password']); |
| 297 | } |
Andrey Andreev | 119d8a7 | 2014-01-08 15:27:53 +0200 | [diff] [blame] | 298 | |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 299 | // Initialize the index of selialized values. |
Ivan Tcholakov | 7c83557 | 2014-08-18 10:37:29 +0300 | [diff] [blame] | 300 | $this->_serialized = $this->_redis->sMembers('_ci_redis_serialized'); |
Ivan Tcholakov | 927e508 | 2014-08-14 04:07:39 +0300 | [diff] [blame] | 301 | |
| 302 | if (empty($this->_serialized)) |
| 303 | { |
| 304 | // On error FALSE is returned, ensure array type for empty index. |
| 305 | $this->_serialized = array(); |
| 306 | } |
| 307 | |
Kakysha | 2d14673 | 2013-10-28 20:20:24 +0400 | [diff] [blame] | 308 | return TRUE; |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 309 | } |
| 310 | |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 311 | // ------------------------------------------------------------------------ |
| 312 | |
| 313 | /** |
Andrey Andreev | 9e674f7 | 2012-06-09 21:02:52 +0300 | [diff] [blame] | 314 | * Class destructor |
| 315 | * |
| 316 | * Closes the connection to Redis if present. |
| 317 | * |
| 318 | * @return void |
| 319 | */ |
| 320 | public function __destruct() |
| 321 | { |
| 322 | if ($this->_redis) |
| 323 | { |
| 324 | $this->_redis->close(); |
| 325 | } |
| 326 | } |
| 327 | |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 328 | } |
Anton Lindqvist | 1e8be29 | 2012-01-21 12:25:08 +0100 | [diff] [blame] | 329 | |
| 330 | /* End of file Cache_redis.php */ |
| 331 | /* Location: ./system/libraries/Cache/drivers/Cache_redis.php */ |