|
|
@ -349,10 +349,18 @@ class rcube_cache_shared
|
|
|
|
$result = $this->add_record($this->ckey($key), $data);
|
|
|
|
$result = $this->add_record($this->ckey($key), $data);
|
|
|
|
|
|
|
|
|
|
|
|
// make sure index will be updated
|
|
|
|
// make sure index will be updated
|
|
|
|
if ($result && !array_key_exists($key, $this->cache_sums)) {
|
|
|
|
if ($result) {
|
|
|
|
|
|
|
|
if (!array_key_exists($key, $this->cache_sums)) {
|
|
|
|
$this->cache_sums[$key] = true;
|
|
|
|
$this->cache_sums[$key] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->load_index();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$this->index_changed && !in_array($key, $this->index)) {
|
|
|
|
|
|
|
|
$this->index_changed = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -409,22 +417,29 @@ class rcube_cache_shared
|
|
|
|
// Remove all keys
|
|
|
|
// Remove all keys
|
|
|
|
if ($key === null) {
|
|
|
|
if ($key === null) {
|
|
|
|
foreach ($this->index as $key) {
|
|
|
|
foreach ($this->index as $key) {
|
|
|
|
$this->delete_record($key, false);
|
|
|
|
$this->delete_record($this->ckey($key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->index = array();
|
|
|
|
$this->index = array();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Remove keys by name prefix
|
|
|
|
// Remove keys by name prefix
|
|
|
|
else if ($prefix_mode) {
|
|
|
|
else if ($prefix_mode) {
|
|
|
|
foreach ($this->index as $k) {
|
|
|
|
foreach ($this->index as $idx => $k) {
|
|
|
|
if (strpos($k, $key) === 0) {
|
|
|
|
if (strpos($k, $key) === 0) {
|
|
|
|
$this->delete_record($k);
|
|
|
|
$this->delete_record($this->ckey($k));
|
|
|
|
|
|
|
|
unset($this->index[$idx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Remove one key by name
|
|
|
|
// Remove one key by name
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
$this->delete_record($key);
|
|
|
|
$this->delete_record($this->ckey($key));
|
|
|
|
|
|
|
|
if (($idx = array_search($key, $this->index)) !== false) {
|
|
|
|
|
|
|
|
unset($this->index[$idx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->index_changed = true;
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -475,21 +490,19 @@ class rcube_cache_shared
|
|
|
|
$this->debug('set', $key, $data, $result);
|
|
|
|
$this->debug('set', $key, $data, $result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
|
|
|
$this->index_changed = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Deletes entry from memcache/apc DB.
|
|
|
|
* Deletes entry from memcache/apc DB.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param string $key Cache key name
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param boolean True on success, False on failure
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function delete_record($key, $index=true)
|
|
|
|
private function delete_record($key)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$ckey = $this->ckey($key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->type == 'memcache') {
|
|
|
|
if ($this->type == 'memcache') {
|
|
|
|
// #1488592: use 2nd argument
|
|
|
|
// #1488592: use 2nd argument
|
|
|
|
$result = $this->db->delete($ckey, 0);
|
|
|
|
$result = $this->db->delete($ckey, 0);
|
|
|
@ -502,15 +515,7 @@ class rcube_cache_shared
|
|
|
|
$this->debug('delete', $ckey, null, $result);
|
|
|
|
$this->debug('delete', $ckey, null, $result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
return $result;
|
|
|
|
$this->index_changed = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($index) {
|
|
|
|
|
|
|
|
if (($idx = array_search($key, $this->index)) !== false) {
|
|
|
|
|
|
|
|
unset($this->index[$idx]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|