public function increment($key, $by_value = 1, $limit_keys_count = 0, $ttl = 259200)
{
if (!$this->acquire_key($key, $auto_unlocker)) {
return false;
}
$value = $this->Couchbase->get($this->prefix . $key);
if (empty($value)) {
if ($this->save($key, $by_value, $ttl)) {
return $by_value;
} else {
return false;
}
}
$expiration = $this->ttl_to_expiration($ttl);
if (is_array($value)) {
$value = $this->incrementArray($limit_keys_count, $value, $by_value);
} elseif (is_numeric($value) && is_numeric($by_value)) {
if ($by_value > 0) {
$this->setKeyTTL($key, $expiration);
return $this->Couchbase->increment($this->prefix . $key, $by_value, true, $expiration);
} else {
$this->setKeyTTL($key, $expiration);
return $this->Couchbase->decrement($this->prefix . $key, $by_value * -1, true, $expiration);
}
} else {
$this->setKeyTTL($key, $expiration);
$this->Couchbase->append($this->prefix . $key, $by_value, $expiration);
return $this->Couchbase->get($this->prefix . $key);
}
if ($this->save($key, $value, $ttl)) {
return $value;
} else {
return false;
}
}