Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

errors triggering by default is turned on

  • Loading branch information...
commit df3266f50b37c57d1cf6284718d3c07202d6a28f 1 parent 2a873d1
@e-oz authored
View
10 APCObject.php
@@ -119,7 +119,7 @@ public function getKeyTTL($key)
{
$i = new \APCIterator('user', '/^'.preg_quote($this->prefix.$key).'$/', APC_ITER_TTL+APC_ITER_CTIME, 1);
$item = $i->current();
- if (empty($item)) $this->ReportError('key '.$key.' not found'.count($i), __LINE__);
+ if (empty($item)) return NULL;
if ($item[self::apc_arr_ttl]!=0) return (($item[self::apc_arr_ctime]+$item[self::apc_arr_ttl])-time());
else return self::max_ttl;
}
@@ -135,7 +135,7 @@ public function read($k, &$ttl_left = -1)
{
if (empty($k))
{
- $this->ReportError('empty key are not allowed', __LINE__);
+ $this->ReportError('empty keys are not allowed', __LINE__);
return NULL;
}
if (is_array($k))
@@ -197,7 +197,7 @@ public function del($k)
{
if (empty($k))
{
- $this->ReportError('empty key are not allowed', __LINE__);
+ $this->ReportError('empty keys are not allowed', __LINE__);
return false;
}
@@ -352,7 +352,7 @@ public function increment($key, $by_value = 1, $limit_keys_count = 0, $ttl = 259
return false;
}
- if (!$this->acquire_key($key, $auto_unlocker)) return $this->ReportError('Can not acquire key', __LINE__);
+ if (!$this->acquire_key($key, $auto_unlocker)) return false;
$value = apc_fetch($this->prefix.$key, $success);
if (!$success)
@@ -407,7 +407,7 @@ public function unlock_key(KeyAutoUnlocker $auto_unlocker)
$key = $auto_unlocker->getKey();
if (empty($key))
{
- $this->ReportError('autoUnlocker should be passed', __LINE__);
+ $this->ReportError('Empty name of key in the AutoUnlocker', __LINE__);
return false;
}
$auto_unlocker->revoke();
View
11 MemcacheObject.php
@@ -33,7 +33,7 @@ protected function setMemcacheObject($host = 'localhost', $port = 11211)
$this->memcache = new \Memcache();
if (!$this->memcache->connect($host, $port))
{
- $this->ReportError('memcache not connected', __LINE__);
+ $this->ReportError('memcache connection error', __LINE__);
}
}
@@ -98,7 +98,7 @@ public function del($key)
{
if (empty($key))
{
- $this->ReportError('empty key are not allowed', __LINE__);
+ $this->ReportError('empty keys are not allowed', __LINE__);
return false;
}
@@ -233,7 +233,7 @@ public function increment($key, $by_value = 1, $limit_keys_count = 0, $ttl = 259
return false;
}
- if (!$this->acquire_key($key, $auto_unlocker)) return $this->ReportError('Can not acquire key', __LINE__);
+ if (!$this->acquire_key($key, $auto_unlocker)) return false;
$value = $this->memcache->get($this->prefix.$key);
if (empty($value))
@@ -288,7 +288,7 @@ public function read($k, &$ttl_left = -1)
{
if (empty($k))
{
- $this->ReportError('empty key are not allowed', __LINE__);
+ $this->ReportError('empty keys are not allowed', __LINE__);
return NULL;
}
if (is_array($k))
@@ -362,7 +362,6 @@ public function save($k, $v, $ttl = 259200, $tags = NULL)
$reason = $this->prefix.$k;
if (strlen($this->prefix.$k) > 250) $reason = 'key length should be <250';
elseif (strlen(serialize($v)) > 1048576) $reason = 'size of value should be <1Mb';
- $this->ReportError('can not add key: '.$reason, __LINE__);
$this->ReportError('memcache can not store key: '.$reason, __LINE__);
return false;
}
@@ -416,7 +415,7 @@ public function unlock_key(KeyAutoUnlocker $auto_unlocker)
$key = $auto_unlocker->getKey();
if (empty($key))
{
- $this->ReportError('autoUnlocker should be passed', __LINE__);
+ $this->ReportError('Empty key in the AutoUnlocker', __LINE__);
return false;
}
$auto_unlocker->revoke();
View
2  MemoryObject.php
@@ -9,7 +9,7 @@
private $last_err;
private $err_log;
- private $errors_triggering = false;
+ private $errors_triggering = true;
public function getLastErr()
{
View
4 RedisObject.php
@@ -191,7 +191,7 @@ public function increment($key, $by_value = 1, $limit_keys_count = 0, $ttl = 259
return false;
}
- if (!$this->acquire_key($key, $auto_unlocker)) return $this->ReportError('Can not acquire key', __LINE__);
+ if (!$this->acquire_key($key, $auto_unlocker)) return false;
$value = $this->read($key);
if ($value===null || $value===false) return $this->save($key, $by_value, $ttl);
@@ -239,7 +239,7 @@ public function unlock_key(KeyAutoUnlocker $auto_unlocker)
$key = $auto_unlocker->getKey();
if (empty($key))
{
- $this->ReportError('autoUnlocker should be passed', __LINE__);
+ $this->ReportError('Empty key in the AutoUnlocker', __LINE__);
return false;
}
$auto_unlocker->revoke();
View
13 Shm/SHMObject.php
@@ -53,13 +53,11 @@ public function add($k, $v, $ttl = 259200, $tags = NULL)
$auto_unlocker = NULL;
if (!$this->mutex->get_access_write($auto_unlocker))
{
- $this->ReportError('write mutex not acquired', __LINE__);
return false;
}
$map = $this->mem_object->read('map');
if (isset($map[$k]))
{
- $this->ReportError('key already exists', __LINE__);
return false;
}
return $this->save($k, $v, $ttl, $tags);
@@ -109,7 +107,6 @@ public function save($k, $v, $ttl = 259200, $tags = NULL)
$auto_unlocker = NULL;
if (!$this->mutex->get_access_write($auto_unlocker))
{
- $this->ReportError('write mutex not acquired', __LINE__);
return false;
}
$map = $this->mem_object->read('map');
@@ -241,7 +238,6 @@ public function read($k, &$ttl_left = -1)
$auto_unlocker = NULL;
if (!$this->mutex->get_access_read($auto_unlocker))
{
- $this->ReportError('read access mutex not acquired', __LINE__);
return NULL;
}
$map = $this->mem_object->read('map');
@@ -291,7 +287,6 @@ public function read($k, &$ttl_left = -1)
$k = (string)$k;
if (!array_key_exists($k, $map))
{
- $this->ReportError('key are not in map', __LINE__);
return NULL;
}
$ttl_left = self::max_ttl;
@@ -300,7 +295,6 @@ public function read($k, &$ttl_left = -1)
$ttl_left = $map[$k][self::map_key_ttl]-time();
if ($ttl_left <= 0)
{
- $this->ReportError('ttl expired', __LINE__);
$this->del($k);
return NULL;
}
@@ -387,7 +381,6 @@ public function del($k)
$auto_unlocker = NULL;
if (!$this->mutex->get_access_write($auto_unlocker))
{
- $this->ReportError('write mutex not acquired', __LINE__);
return false;
}
$map = $this->mem_object->read('map');
@@ -422,7 +415,6 @@ public function del_old()
$auto_unlocker = NULL;
if (!$this->mutex->get_access_write($auto_unlocker))
{
- $this->ReportError('write mutex was not acquired', __LINE__);
return false;
}
$r = 0;
@@ -452,7 +444,6 @@ public function del_by_tags($tag)
$auto_unlocker = NULL;
if (!$this->mutex->get_access_write($auto_unlocker))
{
- $this->ReportError('write mutex not acquired', __LINE__);
return false;
}
$mem_tags = $this->mem_object->read('tags');
@@ -478,7 +469,6 @@ public function select_fx($fx, $get_array = false)
$auto_unlocker = NULL;
if (!$this->mutex->get_access_read($auto_unlocker))
{
- $this->ReportError('read mutex not acquired', __LINE__);
return false;
}
$map = $this->mem_object->read('map');
@@ -519,7 +509,6 @@ public function increment($key, $by_value = 1, $limit_keys_count = 0, $ttl = 259
$auto_unlocker = NULL;
if (!$this->mutex->get_access_write($auto_unlocker))
{
- $this->ReportError('write mutex not acquired', __LINE__);
return false;
}
$map = $this->mem_object->read('map');
@@ -608,7 +597,7 @@ public function unlock_key(\Jamm\Memory\KeyAutoUnlocker $auto_unlocker)
$key = $auto_unlocker->getKey();
if (empty($key))
{
- $this->ReportError('autoUnlocker should be passed', __LINE__);
+ $this->ReportError('Empty key in the AutoUnlocker', __LINE__);
return false;
}
$auto_unlocker->revoke();
View
18 Shm/SingleMemory.php
@@ -27,14 +27,13 @@ public function save($k, $v, $ttl = 2592000, $tags = NULL)
{
if (empty($k) || $v===NULL)
{
- $this->ReportError('empty key and null value are not allowed', __LINE__);
+ $this->ReportError('empty keys and null values are not allowed', __LINE__);
return false;
}
$k = (string)$k;
$auto_unlocker = NULL;
if (!$this->sem->get_access_write($auto_unlocker))
{
- $this->ReportError('can not acquire writers mutex', __LINE__);
return false;
}
@@ -69,7 +68,7 @@ public function read($k, &$ttl_left = -1)
{
if (empty($k))
{
- $this->ReportError('empty key are not allowed', __LINE__);
+ $this->ReportError('empty keys are not allowed', __LINE__);
return false;
}
@@ -136,13 +135,11 @@ public function del($k)
$auto_unlocker = NULL;
if (!$this->sem->get_access_write($auto_unlocker))
{
- $this->ReportError('can not acquire writers mutex', __LINE__);
return false;
}
$this->readmemory();
if (empty($this->mem))
{
- $this->ReportError('memory are empty', __LINE__);
return false;
}
@@ -185,7 +182,6 @@ public function add($key, $value, $ttl = 2592000, $tags = NULL)
$auto_unlocker = NULL;
if (!$this->sem->get_access_write($auto_unlocker))
{
- $this->ReportError('can not acquire writers mutex', __LINE__);
return false;
}
@@ -193,7 +189,6 @@ public function add($key, $value, $ttl = 2592000, $tags = NULL)
$this->readmemory();
if (isset($this->mem[self::map_keys][$key]))
{
- $this->ReportError('key already exists', __LINE__);
return false;
}
@@ -238,14 +233,12 @@ public function del_by_tags($tags)
$auto_unlocker = NULL;
if (!$this->sem->get_access_write($auto_unlocker))
{
- $this->ReportError('can not acquire writers mutex', __LINE__);
return false;
}
$this->readmemory();
if (empty($this->mem[self::map_key_tags]))
{
- $this->ReportError('tags was not found', __LINE__);
return false;
}
@@ -266,7 +259,6 @@ public function del_old()
$auto_unlocker = NULL;
if (!$this->sem->get_access_write($auto_unlocker))
{
- $this->ReportError('can not acquire writers mutex', __LINE__);
return false;
}
@@ -317,7 +309,6 @@ public function increment($key, $by_value = 1, $limit_keys_count = 0, $ttl = 259
$auto_unlocker = NULL;
if (!$this->sem->get_access_write($auto_unlocker))
{
- $this->ReportError('can not acquire writers mutex', __LINE__);
return false;
}
@@ -356,7 +347,6 @@ public function lock_key($key, &$auto_unlocker_variable)
$auto_unlocker = NULL;
if (!$this->sem->get_access_write($auto_unlocker))
{
- $this->ReportError('can not acquire writers mutex', __LINE__);
return false;
}
$this->readmemory();
@@ -364,7 +354,6 @@ public function lock_key($key, &$auto_unlocker_variable)
if (isset($this->mem[self::map_key_locks][$key]))
{
- $this->ReportError('key locked', __LINE__);
return false;
}
@@ -388,14 +377,13 @@ public function unlock_key(\Jamm\Memory\KeyAutoUnlocker $key_auto_unlocker)
$key = $key_auto_unlocker->getKey();
if (empty($key))
{
- $this->ReportError('autoUnlocker should be passed', __LINE__);
+ $this->ReportError('Empty key in the AutoUnlocker', __LINE__);
return false;
}
$key_auto_unlocker->revoke();
if (!$this->sem->get_access_write($auto_unlocker))
{
- $this->ReportError('can not acquire writers mutex', __LINE__);
return false;
}
$this->readmemory();
Please sign in to comment.
Something went wrong with that request. Please try again.