public function increment($key, $by_value = 1, $limit_keys_count = 0, $ttl = 259200)
{
if (empty($key)) {
$this->ReportError('empty key can not be incremented', __LINE__);
return false;
}
$auto_unlocker = NULL;
if (!$this->mutex->get_access_write($auto_unlocker)) {
return false;
}
$map = $this->mem_object->read('map');
if (!array_key_exists($key, $map)) {
if ($this->save($key, $by_value, $ttl)) {
return $by_value;
} else {
return false;
}
}
$value = $this->read($key);
if (is_array($value)) {
$value = $this->incrementArray($limit_keys_count, $value, $by_value);
} elseif (is_numeric($value) && is_numeric($by_value)) {
$value += $by_value;
} else {
$value .= $by_value;
}
$this->save($key, $value, $ttl);
return $value;
}