From fa3f2e9c2dcf1fdf329778a77c2dfd2d4416f131 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 28 Feb 2013 22:17:40 +0100 Subject: memcachelibrary: Ignore server unreachable errors in set() and delete() Signed-off-by: Florian Pritz --- application/libraries/MemcacheLibrary.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'application/libraries/MemcacheLibrary.php') diff --git a/application/libraries/MemcacheLibrary.php b/application/libraries/MemcacheLibrary.php index dc993b7a5..1716a1d10 100644 --- a/application/libraries/MemcacheLibrary.php +++ b/application/libraries/MemcacheLibrary.php @@ -110,7 +110,15 @@ class MemcacheLibrary { $this->logDebugMessage( sprintf("%s key set to memcache. (expire: %s)",$key, $expire) ); - return $this->memcachedInstance->set($key, $value, null, $expire); + + // hide notice if server is unreachable + $old_error_level = error_reporting(); + error_reporting($old_error_level & ~E_NOTICE); + + $ret = $this->memcachedInstance->set($key, $value, null, $expire); + + error_reporting($old_error_level); + return $ret; } /** @@ -120,7 +128,14 @@ class MemcacheLibrary { */ public function delete($key) { $this->logDebugMessage(sprintf("%s key deleted from memcache.", $key)); - return $this->memcachedInstance->delete($key); + // hide notice if server is unreachable + $old_error_level = error_reporting(); + error_reporting($old_error_level & ~E_NOTICE); + + $ret = $this->memcachedInstance->delete($key); + + error_reporting($old_error_level); + return $ret; } /** -- cgit v1.2.3-24-g4f1b