Skip to content
Snippets Groups Projects
Verified Commit 105841e9 authored by Alberto Paderno's avatar Alberto Paderno
Browse files

Issue #3463180: Replace DrupalApcCache::binKey() and DrupalApcCache::key()...

Issue #3463180: Replace DrupalApcCache::binKey() and DrupalApcCache::key() with DrupalApcCache::keyName()
parent 0d96bb66
No related branches found
No related tags found
1 merge request!25Issue #3463180: Replace DrupalApcCache::binKey() and DrupalApcCache::key() with DrupalApcCache::keyName()
Pipeline #231499 passed
......@@ -143,16 +143,6 @@ public function __construct($bin) {
$this->addModulePrefix();
}
/**
* Gets the key to use for the cache bin in APC calls.
*
* @return string
* The key to use for the cache bin.
*/
private function binKey() {
return $this->prefix . $this->bin . '::';
}
/**
* Gets the key to use in APC calls.
*
......@@ -163,8 +153,14 @@ private function binKey() {
* The key which can be used in APC calls to avoid conflicts with other
* keys.
*/
private function key($cid) {
return $this->binKey() . $cid;
protected function keyName($cid = NULL) {
$key_name = $this->prefix . $this->bin;
if (!is_null($cid)) {
$key_name .= '::' . $cid;
}
return $key_name;
}
/**
......@@ -174,7 +170,7 @@ public function get($cid) {
// Add a get to our statistics.
$GLOBALS['_apc_statistics'][] = array('get', $this->bin, array($cid));
return $this->prepareItem(apcu_fetch($this->key($cid)));
return $this->prepareItem(apcu_fetch($this->keyName($cid)));
}
/**
......@@ -207,7 +203,7 @@ public function getMultiple(&$cids) {
}
foreach ($cids as $cid) {
$data = apcu_fetch($this->key($cid), $success);
$data = apcu_fetch($this->keyName($cid), $success);
if ($success) {
$cache[$cid] = $this->prepareItem($data);
......@@ -254,7 +250,7 @@ public function set($cid, $data, $expire = CACHE_PERMANENT) {
break;
}
apcu_store($this->key($cid), $cache, $ttl);
apcu_store($this->keyName($cid), $cache, $ttl);
}
/**
......@@ -265,7 +261,7 @@ public function set($cid, $data, $expire = CACHE_PERMANENT) {
*/
protected function deletePrefix($prefix) {
if (class_exists('APCUIterator')) {
$escaped_key = preg_quote($this->binKey() . $prefix, '/');
$escaped_key = preg_quote($this->keyName($prefix), '/');
$iterator = new APCUIterator("/^$escaped_key/", APC_ITER_KEY);
apcu_delete($iterator);
}
......@@ -307,11 +303,11 @@ public function clear($cid = NULL, $wildcard = FALSE) {
}
elseif (is_array($cid)) {
foreach ($cid as $entry) {
apcu_delete($this->key($entry));
apcu_delete($this->keyName($entry));
}
}
else {
apcu_delete($this->key($cid));
apcu_delete($this->keyName($cid));
}
}
}
......@@ -321,7 +317,7 @@ public function clear($cid = NULL, $wildcard = FALSE) {
*/
public function isEmpty() {
if (class_exists('APCUIterator')) {
$escaped_key = preg_quote($this->binKey(), '/');
$escaped_key = preg_quote($this->keyName(), '/');
$iterator = new APCUIterator('/^' . $escaped_key . '/', APC_ITER_KEY);
return $iterator->getTotalCount() === 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment