Commit 124e5288 authored by totten's avatar totten

(#174) CRM_Utils_Cache_Interface::flush() - Return bool like PSR-16

The function signature for `flush()` did not specify a return value, and
actual behaviors varied depending on the driver (`bool` for memcache,
`int` for redis, and `void` for others).

This standardizes on returning a bool -- which makes the signature align
with PSR-16's `clear()`.
parent 0d64c8fa
......@@ -124,6 +124,7 @@ class CRM_Utils_Cache_APCcache implements CRM_Utils_Cache_Interface {
apc_delete($this->_prefix . $name);
}
}
return TRUE;
}
}
......@@ -89,6 +89,7 @@ class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface {
public function flush() {
unset($this->_cache);
$this->_cache = array();
return TRUE;
}
}
......@@ -86,6 +86,8 @@ interface CRM_Utils_Cache_Interface {
/**
* Delete all values from the cache.
*
* @return bool
*/
public function flush();
......
......@@ -150,7 +150,7 @@ class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface {
}
/**
* @return mixed
* @return bool
*/
public function flush() {
// FIXME: Only delete items matching `$this->_prefix`.
......
......@@ -172,7 +172,7 @@ class CRM_Utils_Cache_Memcached implements CRM_Utils_Cache_Interface {
}
/**
* @return mixed
* @return bool
*/
public function flush() {
// FIXME: Only delete items matching `$this->_prefix`.
......
......@@ -159,7 +159,7 @@ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface {
}
/**
* @return mixed
* @return bool
*/
public function flush() {
// FIXME: Ideally, we'd map each prefix to a different 'hash' object in Redis,
......@@ -167,7 +167,8 @@ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface {
// more general rethink of cache expiration/TTL.
$keys = $this->_cache->keys($this->_prefix . '*');
return $this->_cache->del($keys);
$this->_cache->del($keys);
return TRUE;
}
}
......@@ -119,11 +119,12 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface {
/**
* @param null $key
* @return bool
*/
public function flush($key = NULL) {
$prefix = "CRM_";
if (!$handle = opendir(CIVICRM_TEMPLATE_COMPILEDIR)) {
return; // die? Error?
return FALSE; // die? Error?
}
while (FALSE !== ($entry = readdir($handle))) {
if (substr($entry, 0, 4) == $prefix) {
......@@ -133,6 +134,7 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface {
closedir($handle);
unset($this->_cache);
$this->_cache = array();
return TRUE;
}
}
......@@ -144,6 +144,7 @@ class CRM_Utils_Cache_SqlGroup implements CRM_Utils_Cache_Interface {
CRM_Core_BAO_Cache::$_cache = NULL; // FIXME: remove multitier cache
CRM_Utils_Cache::singleton()->flush(); // FIXME: remove multitier cache
$this->frontCache = array();
return TRUE;
}
public function prefetch() {
......
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