Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function decrement($key, $offset = 1, $expire = 0, $create = true)
 {
     $hash = $this->prepareKey($key);
     if (!$create && $this->exists($key) === false) {
         return false;
     }
     return $this->storage->counter($hash, $offset * -1, ['expiry' => $expire, 'initial' => 0])->value;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function decrement($key, $offset = 1, $initial = 0, $expire = 0)
 {
     if ($offset <= 0 || $initial < 0) {
         return false;
     }
     try {
         $result = $this->client->counter($key, -$offset, array('initial' => $initial, 'expiry' => $expire));
         /*
          * Negative expire here doesn't properly seem to expire immediately.
          * Unfortunately, we still had to do the counter request to figure
          * out the correct return value.
          */
         if ($expire < 0 || $expire > 2592000 && $expire < time()) {
             $this->delete($key);
         }
     } catch (\CouchbaseException $e) {
         return false;
     }
     return $result->error ? false : $result->value;
 }
Ejemplo n.º 3
0
 protected function doIncrement($key, $delta = 1)
 {
     $meta = $this->bucket->counter($key, $delta);
     KalturaLog::debug("key [{$key}], meta [" . print_r($meta, true) . "]");
     return $meta->value;
 }