Add support for closures to File cache driver.
This commit is contained in:
parent
ac38876e34
commit
715bed748d
|
@ -36,20 +36,17 @@ public function get($key, $default = null)
|
||||||
|
|
||||||
if ( ! file_exists(APP_PATH.'storage/cache/'.$key))
|
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);
|
$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))
|
if (time() >= substr($cache, 0, 10))
|
||||||
{
|
{
|
||||||
$this->forget($key);
|
$this->forget($key);
|
||||||
|
|
||||||
return $default;
|
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));
|
||||||
|
|
Loading…
Reference in New Issue