Commit 577066e0 authored by Taylor Otwell's avatar Taylor Otwell

Tweak file cache driver to return null as default.

parent 9927e3ed
...@@ -27,7 +27,7 @@ class File implements \System\Cache\Driver { ...@@ -27,7 +27,7 @@ class File implements \System\Cache\Driver {
* @param mixed $default * @param mixed $default
* @return mixed * @return mixed
*/ */
public function get($key, $default = null) public function get($key)
{ {
if (array_key_exists($key, $this->items)) if (array_key_exists($key, $this->items))
{ {
...@@ -36,17 +36,14 @@ class File implements \System\Cache\Driver { ...@@ -36,17 +36,14 @@ class File implements \System\Cache\Driver {
if ( ! file_exists(APP_PATH.'storage/cache/'.$key)) if ( ! file_exists(APP_PATH.'storage/cache/'.$key))
{ {
return is_callable($default) ? call_user_func($default) : $default; return null;
} }
$cache = file_get_contents(APP_PATH.'storage/cache/'.$key); $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.
if (time() >= substr($cache, 0, 10)) if (time() >= substr($cache, 0, 10))
{ {
$this->forget($key); return $this->forget($key);
return is_callable($default) ? call_user_func($default) : $default;
} }
return $this->items[$key] = unserialize(substr($cache, 10)); return $this->items[$key] = unserialize(substr($cache, 10));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment