summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2016-05-25 14:56:32 +0200
committerChristian Schneider2016-05-25 14:56:32 +0200
commit89a2fe5ba2dfbac07495fd1edbd1fb7e6fff1950 (patch)
tree980b8b0cd05f408ba9772b3222902d64728c0fa3
parent1daeb3976e0349d060c0ab938ec263196fab7614 (diff)
downloaditools-89a2fe5ba2dfbac07495fd1edbd1fb7e6fff1950.tar.gz
itools-89a2fe5ba2dfbac07495fd1edbd1fb7e6fff1950.tar.bz2
itools-89a2fe5ba2dfbac07495fd1edbd1fb7e6fff1950.zip
Added parameter safety => 0 to suppress an it::error in case of failure in it_cache::put()
-rw-r--r--it_cache.class4
1 files changed, 3 insertions, 1 deletions
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