Ejemplo n.º 1
0
 /**
  * 缓存一行数据
  */
 public function getCacheOne($sql, $expire, $mode = MYSQL_BOTH, $key = false)
 {
     $key = $key === false ? md5($sql) : $key;
     if (($temp = ocache::cache()->get($key)) === false) {
         $temp = $this->getOne($sql, $mode);
         ocache::cache()->set($key, $temp, $expire);
     }
     return $temp;
 }
Ejemplo n.º 2
0
 /**
  * 删除$keys对应的记录(不管有没有存在)相当于Memcached的delete但这里可以一次删多记录 成功为true
  * $keys为字符串或数组
  */
 public function out($keys)
 {
     return ocache::cache()->delete($keys);
     if (!$this->connect()) {
         return false;
     }
     try {
         $flag = true;
         $this->oTyrant->out($keys);
     } catch (TokyoTyrantException $e) {
         $flag = false;
         $this->errorlog($keys, $e->getCode(), $e->getMessage());
     }
     return $flag;
 }