From 2f083f76081b935d3561a6ed4f20263b01a4b2c8 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 8 Jun 2017 09:37:38 +0100 Subject: [PATCH] more useful memcached error messages --- core/database.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/database.class.php b/core/database.class.php index 2ab4230e..b63d3d1d 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -399,6 +399,7 @@ class MemcachedCache implements CacheEngine { */ public function get($key) { assert('!is_null($key)'); + $key = urlencode($key); $val = $this->memcache->get($key); $res = $this->memcache->getResultCode(); @@ -416,7 +417,7 @@ class MemcachedCache implements CacheEngine { return false; } else { - error_log("Memcached error: $res"); + error_log("Memcached error during get($key): $res"); } } @@ -427,11 +428,16 @@ class MemcachedCache implements CacheEngine { */ public function set($key, $val, $time=0) { assert('!is_null($key)'); + $key = urlencode($key); $this->memcache->set($key, $val, $time); + $res = $this->memcache->getResultCode(); if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) { file_put_contents("data/cache.log", "Cache set: $key ($time)\n", FILE_APPEND); } + if($res != Memcached::RES_SUCCESS) { + error_log("Memcached error during set($key): $res"); + } } /** @@ -439,11 +445,16 @@ class MemcachedCache implements CacheEngine { */ public function delete($key) { assert('!is_null($key)'); + $key = urlencode($key); $this->memcache->delete($key); + $res = $this->memcache->getResultCode(); if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) { file_put_contents("data/cache.log", "Cache delete: $key\n", FILE_APPEND); } + if($res != Memcached::RES_SUCCESS && $res != Memcached::RES_NOTFOUND) { + error_log("Memcached error during delete($key): $res"); + } } /**