From 715bed748d7a9781a735b609ce9f6ff227709220 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 7 Jul 2011 07:29:16 -0700 Subject: [PATCH] Add support for closures to File cache driver. --- system/cache/driver/file.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/system/cache/driver/file.php b/system/cache/driver/file.php index 0994f75d..ce5128b7 100644 --- a/system/cache/driver/file.php +++ b/system/cache/driver/file.php @@ -36,20 +36,17 @@ public function get($key, $default = null) if ( ! file_exists(APP_PATH.'storage/cache/'.$key)) { - return $default; + return is_callable($default) ? call_user_func($default) : $default; } $cache = file_get_contents(APP_PATH.'storage/cache/'.$key); - // -------------------------------------------------- - // Has the cache expired? The UNIX expiration time - // is stored at the beginning of the file. - // -------------------------------------------------- + // 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 is_callable($default) ? call_user_func($default) : $default; } return $this->items[$key] = unserialize(substr($cache, 10));