Phalcon\Cache\Backend\Aerospike::increment PHP Метод

increment() публичный Метод

Increment of given $keyName by $value
public increment ( string $keyName = null, integer $value = null ) : integer | false
$keyName string
$value integer
Результат integer | false
    public function increment($keyName = null, $value = null)
    {
        if ($keyName === null) {
            $prefixedKey = $this->_lastKey;
        } else {
            $prefixedKey = $this->getPrefixedIdentifier($keyName);
        }
        if (!$prefixedKey) {
            return false;
        }
        $this->_lastKey = $prefixedKey;
        if (!$value) {
            $value = 1;
        }
        $aKey = $this->buildKey($prefixedKey);
        $this->db->increment($aKey, 'value', $value);
        $status = $this->db->get($aKey, $cache);
        if ($status != \Aerospike::OK) {
            return false;
        }
        return $cache['bins']['value'];
    }

Usage Example

Пример #1
0
 /**
  * Increment of given $keyName by $value
  *
  * @param  string $keyName
  * @param  int    $value
  * @return int|false
  */
 public function increment($keyName = null, $value = null)
 {
     if ($keyName === null) {
         $prefixedKey = $this->_lastKey;
     } else {
         $prefixedKey = $this->getPrefixedIdentifier($keyName);
     }
     if (!$prefixedKey) {
         return false;
     }
     $this->_lastKey = $prefixedKey;
     if (!$value) {
         $value = 1;
     }
     $aKey = $this->buildKey($prefixedKey);
     $this->db->increment($aKey, 'value', $value);
     $status = $this->db->get($aKey, $cache);
     if ($status != AerospikeDb::OK) {
         return false;
     }
     return $cache['bins']['value'];
 }