Commit eec321a4 authored by totten's avatar totten

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

The function signature for `delete()` 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 `delete()`.
parent 124e5288
......@@ -81,9 +81,11 @@ class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface {
/**
* @param string $key
* @return bool
*/
public function delete($key) {
unset($this->_cache[$key]);
return TRUE;
}
public function flush() {
......
......@@ -81,6 +81,7 @@ interface CRM_Utils_Cache_Interface {
* Delete a value from the cache.
*
* @param string $key
* @return bool
*/
public function delete($key);
......
......@@ -143,7 +143,7 @@ class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface {
/**
* @param $key
*
* @return mixed
* @return bool
*/
public function delete($key) {
return $this->_cache->delete($this->_prefix . $key);
......
......@@ -152,10 +152,11 @@ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface {
/**
* @param $key
*
* @return mixed
* @return bool
*/
public function delete($key) {
return $this->_cache->delete($this->_prefix . $key);
$this->_cache->delete($this->_prefix . $key);
return TRUE;
}
/**
......
......@@ -109,12 +109,14 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface {
/**
* @param string $key
* @return bool
*/
public function delete($key) {
if (file_exists($this->fileName($key))) {
unlink($this->fileName($key));
}
unset($this->_cache[$key]);
return TRUE;
}
/**
......
......@@ -131,12 +131,14 @@ class CRM_Utils_Cache_SqlGroup implements CRM_Utils_Cache_Interface {
/**
* @param string $key
* @return bool
*/
public function delete($key) {
CRM_Core_BAO_Cache::deleteGroup($this->group, $key, FALSE);
CRM_Core_BAO_Cache::$_cache = NULL; // FIXME: remove multitier cache
CRM_Utils_Cache::singleton()->flush(); // FIXME: remove multitier cache
unset($this->frontCache[$key]);
return TRUE;
}
public function flush() {
......
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