summaryrefslogtreecommitdiff
path: root/it_cache.class
diff options
context:
space:
mode:
authorUrban Müller2022-11-17 17:59:45 +0100
committerUrban Müller2022-11-17 17:59:45 +0100
commit65fd37a0c26be5b7c4403bb71c59c8119d1a8d77 (patch)
tree9bc9ff476fb54bc4864a1061509dbd175fbc4afb /it_cache.class
parente4ed34fc4f188e8ac9ef040818e3090f880a090a (diff)
downloaditools-65fd37a0c26be5b7c4403bb71c59c8119d1a8d77.tar.gz
itools-65fd37a0c26be5b7c4403bb71c59c8119d1a8d77.tar.bz2
itools-65fd37a0c26be5b7c4403bb71c59c8119d1a8d77.zip
fall back to apc if memcache is down, hopefully solves trouble when login down
Diffstat (limited to 'it_cache.class')
-rw-r--r--it_cache.class10
1 files changed, 6 insertions, 4 deletions
diff --git a/it_cache.class b/it_cache.class
index 69f9498..081db65 100644
--- a/it_cache.class
+++ b/it_cache.class
@@ -56,7 +56,8 @@ static function get($key, $p = array())
$result = @$memcache->get($key);
$success = !$memcache->getResultCode();
}
- else
+
+ if (!$success)
$result = ($func = self::$_fetch_func) ? $func($key, $success) : null;
return $success === false ? null : $result;
@@ -76,11 +77,12 @@ static function put($key, $value, $p = array())
$p = it_cache::_defaults($p);
if ($p['distributed'] && ($memcache = it_cache::_get_memcache($p)))
- $success = @$memcache->set($key, $value, $p['ttl']);
- else
+ $success = $memsuccess = @$memcache->set($key, $value, $p['ttl']);
+
+ if (!$success)
$success = ($func = self::$_store_func) ? $func($key, $value, $p['ttl']) : null;
- if (!$success && $p['safety'] == 1)
+ if ($memsuccess === false && $p['safety'] == 1)
it::error(array_filter([
'title' => ($p['distributed'] ? "memcache (" . ($memcache ? ($memcache->getResultMessage() . " on " . $memcache->getServerByKey($key)['host']) : "n/a") . ")" : self::$_store_func) . " in it_cache::put failed",
'body' => "key='$key'",