Example #1
0
 /**
  * 原子自减操作,可用于整形或浮点型列
  *
  * @param $key
  * @param $column
  * @param $decrby
  * @return bool|int
  */
 function decr($key, $column, $decrby = 1)
 {
     if ($this->_link) {
         $rs = parent::incr($key, $column, $decrby);
         if (false === $rs) {
             return false;
         }
         if (false === $this->_driverSet($key, [$column => $rs])) {
             # 重试
             usleep(300);
             $this->_driverSet($key, [$column => $rs]);
         }
         return $rs;
     } else {
         return parent::decr($key, $column, $decrby);
     }
 }