From 89a2fe5ba2dfbac07495fd1edbd1fb7e6fff1950 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 25 May 2016 14:56:32 +0200 Subject: Added parameter safety => 0 to suppress an it::error in case of failure in it_cache::put() --- it_cache.class | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/it_cache.class b/it_cache.class index 3fd154d..91916ea 100644 --- a/it_cache.class +++ b/it_cache.class @@ -30,6 +30,7 @@ static function _defaults($p) 'ttl' => 2, 'distributed' => false, 'hostsfile' => '/opt/ultra/etc/memcached.hosts', + 'safety' => 1, ); if (!it::is_live() && !$p['distributed_on_devel']) @@ -71,6 +72,7 @@ static function get($key, $p = array()) * @param $value Value to put (mixed but no objects allowed) * @param $p['distributed'] Use distributed memcache (scalars may become strings) [false] * @param $p['ttl'] Time to live for this key/value-pair in seconds + * @param $p['safety'] set to 0 to suppress an it::error in case of failure [1] * @return Returns $value */ static function put($key, $value, $p = array()) @@ -82,7 +84,7 @@ static function put($key, $value, $p = array()) else $success = ($func = self::$_store_func) ? $func($key, $value, $p['ttl']) : null; - if (!$success) + if (!$success && $p['safety'] == 1) it::error(array('title' => ($p['distributed'] ? "memcache" : self::$_store_func) . " in it_cache::put failed for key '$key'", 'id' => "it_cache_put", 'graceperiod' => 60, 'timewindow' => 10)); $GLOBALS['it_cache_local'][$key] = $value; # Also store local copy -- cgit v1.2.3