From 11d5e7c1002ec281c57b1181487e448b91e19b80 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 12 May 2015 13:50:02 -0400
Subject: [PATCH] Implemented memcache_debug also for session operations
---
program/lib/Roundcube/rcube_cache_shared.php | 41 +++++++++++++----------------------------
1 files changed, 13 insertions(+), 28 deletions(-)
diff --git a/program/lib/Roundcube/rcube_cache_shared.php b/program/lib/Roundcube/rcube_cache_shared.php
index 37eb4bd..701f8d7 100644
--- a/program/lib/Roundcube/rcube_cache_shared.php
+++ b/program/lib/Roundcube/rcube_cache_shared.php
@@ -47,8 +47,6 @@
private $cache_sums = array();
private $max_packet = -1;
- const DEBUG_LINE_LENGTH = 4096;
-
/**
* Object constructor.
@@ -260,7 +258,15 @@
}
if ($this->type != 'db') {
- if ($this->type == 'memcache') {
+ $this->load_index();
+
+ // Consistency check (#1490390)
+ if (!in_array($key, $this->index)) {
+ // we always check if the key exist in the index
+ // to have data in consistent state. Keeping the index consistent
+ // is needed for keys delete operation when we delete all keys or by prefix.
+ }
+ else if ($this->type == 'memcache') {
$ckey = $this->ckey($key);
$data = $this->db->get($ckey);
@@ -441,13 +447,12 @@
/**
* Adds entry into memcache/apc DB.
*
- * @param string $key Cache key name
- * @param mxied $data Serialized cache data
- * @param bollean $index Enables immediate index update
+ * @param string $key Cache key name
+ * @param mixed $data Serialized cache data
*
* @param boolean True on success, False on failure
*/
- private function add_record($key, $data, $index=false)
+ private function add_record($key, $data)
{
if ($this->type == 'memcache') {
$result = $this->db->replace($key, $data, MEMCACHE_COMPRESSED, $this->ttl);
@@ -466,17 +471,6 @@
if ($this->debug) {
$this->debug('store', $key, $data, $result);
- }
- }
-
- // Update index
- if ($index && $result) {
- $this->load_index();
-
- if (array_search($key, $this->index) === false) {
- $this->index[] = $key;
- $data = serialize($this->index);
- $this->add_record($this->ikey(), $data);
}
}
@@ -663,17 +657,8 @@
if ($data !== null) {
$line .= ' ' . ($this->packed ? $data : serialize($data));
-
- if (($len = strlen($line)) > self::DEBUG_LINE_LENGTH) {
- $diff = $len - self::DEBUG_LINE_LENGTH;
- $line = substr($line, 0, self::DEBUG_LINE_LENGTH) . "... [truncated $diff bytes]";
- }
}
- if ($result !== null) {
- $line .= ' [' . ($result ? 'TRUE' : 'FALSE') . ']';
- }
-
- rcube::write_log($this->type, $line);
+ rcube::debug($this->type, $line, $result);
}
}
--
Gitblit v1.9.1