Example #1
0
 /**
  * 递增
  *
  * @param string $key
  * @param int $offset
  * @param int $lifetime 当递减失则时当作set使用
  */
 public function increment($key, $offset = 1, $lifetime = 60)
 {
     # 首先尝试递增
     $s = $this->_handler->value_increment('number', $offset)->where('key', md5($this->prefix . $key))->update($this->tablename, array('value' => ''));
     if (!$s) {
         # 没有更新到数据,尝试插入数据
         return $this->set($key, $offset, $lifetime);
     }
     return false;
 }
Example #2
0
 /**
  * 递增
  *
  * @param string $key
  * @param int $offset
  * @param int $lifetime 当递减失则时当作set使用
  */
 public function increment($key, $offset = 1, $lifetime = 60)
 {
     $k = \md5($key);
     # 首先尝试递增
     $s = $this->db->value_increment('value', $offset)->where('key', $k)->update($this->tablename);
     if (!$s) {
         # 没有更新到数据,尝试插入数据
         return $this->set($key, $offset, $lifetime);
     }
     return false;
 }