merged skunkworks into develop.

This commit is contained in:
Taylor Otwell
2012-01-16 13:59:24 -06:00
parent 610d8827c4
commit b5442c67fc
117 changed files with 7268 additions and 3999 deletions

View File

@@ -28,9 +28,7 @@ abstract class Driver {
*/
public function get($key, $default = null)
{
if ( ! is_null($item = $this->retrieve($key))) return $item;
return ($default instanceof Closure) ? call_user_func($default) : $default;
return ( ! is_null($item = $this->retrieve($key))) ? $item : value($default);
}
/**
@@ -57,8 +55,7 @@ abstract class Driver {
abstract public function put($key, $value, $minutes);
/**
* Get an item from the cache. If the item doesn't exist in the
* cache, store the default value in the cache and return it.
* Get an item from the cache, or cache and return the default value.
*
* <code>
* // Get an item from the cache, or cache a value for 15 minutes
@@ -77,9 +74,7 @@ abstract class Driver {
{
if ( ! is_null($item = $this->get($key, null))) return $item;
$default = ($default instanceof Closure) ? call_user_func($default) : $default;
$this->put($key, $default, $minutes);
$this->put($key, value($default), $minutes);
return $default;
}
@@ -92,4 +87,15 @@ abstract class Driver {
*/
abstract public function forget($key);
/**
* Get the expiration time as a UNIX timestamp.
*
* @param int $minutes
* @return int
*/
protected function expiration($minutes)
{
return time() + ($minutes * 60);
}
}