From 7ce9c6f2703421b8a4c1363004d85b7730ec22aa Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 17 Jun 2011 11:21:42 -0700 Subject: [PATCH] Improved comments in memcached cache driver. --- system/cache/driver/file.php | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/system/cache/driver/file.php b/system/cache/driver/file.php index 852bdb15..dfe4eb55 100644 --- a/system/cache/driver/file.php +++ b/system/cache/driver/file.php @@ -1,6 +1,6 @@ items)) @@ -34,25 +34,14 @@ class File implements \System\Cache\Driver { return $this->items[$key]; } - if ( ! file_exists(APP_PATH.'cache/'.$key)) + $cache = \System\Memcached::instance()->get(\System\Config::get('cache.key').$key); + + if ($cache === false) { return $default; } - $cache = file_get_contents(APP_PATH.'cache/'.$key); - - // -------------------------------------------------- - // Has the cache expired? The UNIX expiration time - // is stored at the beginning of the file. - // -------------------------------------------------- - if (time() >= substr($cache, 0, 10)) - { - $this->forget($key); - - return $default; - } - - return $this->items[$key] = unserialize(substr($cache, 10)); + return $this->items[$key] = $cache; } /** @@ -65,7 +54,7 @@ class File implements \System\Cache\Driver { */ public function put($key, $value, $minutes) { - file_put_contents(APP_PATH.'cache/'.$key, (time() + ($minutes * 60)).serialize($value), LOCK_EX); + \System\Memcached::instance()->set(\System\Config::get('cache.key').$key, $value, 0, $minutes * 60); } /** @@ -76,7 +65,7 @@ class File implements \System\Cache\Driver { */ public function forget($key) { - @unlink(APP_PATH.'cache/'.$key); + \System\Memcached::instance()->delete(\System\Config::get('cache.key').$key); } } \ No newline at end of file