Skip to content

Commit

Permalink
Cleaning up Cache container.
Browse files Browse the repository at this point in the history
  • Loading branch information
jperras committed Jan 1, 2010
1 parent 77d562b commit 5efea8f
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions libraries/lithium/storage/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public static function write($name, $key, $data, $expiry, $conditions = null) {
}

$key = static::key($key);
$method = static::adapter($name)->write($key, $data, $expiry, $conditions);
$params = compact('key', 'data', 'expiry', 'conditions');
$method = static::adapter($name)->write($key, $data, $expiry);
$params = compact('key', 'data', 'expiry');
return static::_filter(__FUNCTION__, $params, $method, $settings[$name]['filters']);
}

Expand All @@ -116,12 +116,13 @@ public static function read($name, $key, $conditions = null) {
return false;
}

if (is_callable($conditions)) {
if (!$conditions()) return false;
if (is_callable($conditions) && !$conditions()) {
return false;
}

$key = static::key($key);
$method = static::adapter($name)->read($key, $conditions);
$params = compact('key', 'conditions');
$method = static::adapter($name)->read($key);
$params = compact('key');
$filters = $settings[$name]['filters'];

return static::_filter(__FUNCTION__, $params, $method, $filters);
Expand All @@ -142,12 +143,13 @@ public static function delete($name, $key, $conditions = null) {
return false;
}

if (is_callable($conditions)) {
if (!$conditions()) return false;
if (is_callable($conditions) && !$conditions()) {
return false;
}

$key = static::key($key);
$method = static::adapter($name)->delete($key, $conditions);
$params = compact('key', 'conditions');
$method = static::adapter($name)->delete($key);
$params = compact('key');
$filters = $settings[$name]['filters'];

return static::_filter(__FUNCTION__, $params, $method, $filters);
Expand All @@ -168,9 +170,10 @@ public static function increment($name, $key, $offset = 1, $conditions = null) {
return false;
}

if (is_callable($conditions)) {
if (!$conditions()) return false;
if (is_callable($conditions) && !$conditions()) {
return false;
}

$key = static::key($key);
$method = static::adapter($name)->increment($key, $offset);
$params = compact('key', 'offset');
Expand All @@ -194,9 +197,10 @@ public static function decrement($name, $key, $offset = 1, $conditions = null) {
return false;
}

if (is_callable($conditions)) {
if (!$conditions()) return false;
if (is_callable($conditions) && !$conditions()) {
return false;
}

$key = static::key($key);
$method = static::adapter($name)->decrement($key, $offset);
$params = compact('key', 'offset');
Expand All @@ -208,6 +212,8 @@ public static function decrement($name, $key, $offset = 1, $conditions = null) {
/**
* Perform garbage collection on specified cache configuration.
*
* This method is non-filterable.
*
* @param string $name The cache configuration to be cleaned
* @return boolean True on successful clean, false otherwise
*/
Expand All @@ -219,6 +225,8 @@ public static function clean($name) {
/**
* Remove all cache keys from specified confiuration.
*
* This method is non-filterable.
*
* @param string $name The cache configuration to be cleared
* @return boolean True on successful clearing, false otherwise
*/
Expand Down

0 comments on commit 5efea8f

Please sign in to comment.