示例#1
0
文件: cache.php 项目: actcms/nowphp
 /**
  * 进行自增操作,
  * @author 欧远宁
  * @param string $id   cache的key
  * @param int $num     自增数值,可以为负数
  * @param int $default 没有值的时候的默认值
  */
 public function inc($id, $num = 1, $default = 0)
 {
     if (key_exists($id, $this->buf_list)) {
         if ($this->buf_list[$id][0] == '') {
             $this->buf_list[$id][0] = 0;
         }
         $this->buf_list[$id][0] = $this->buf_list[$id][0] + $num;
         $this->buf_list[$id][1] = 0;
     } else {
         if (key_exists($id, $this->del_list)) {
             unset($this->del_list[$id]);
         }
         $this->open();
         try {
             $old = $this->mem_cls->get($id);
         } catch (Exception $e) {
             $old = '';
         }
         if ($old === '') {
             $this->buf_list[$id] = array($default + $num, 0);
         } else {
             $this->buf_list[$id] = array($old + $num, 0);
         }
     }
 }
示例#2
0
文件: dao.php 项目: actcms/nowphp
 /**
  * 根据筛选条件获取所有的id列表
  * @author 欧远宁
  * @param array $filter 筛选条件
  * @param array $page   分页信息
  * @param array $order  排序信息
  * @return array        结果集
  */
 private function get_rec($filter, $page = null, $order = null)
 {
     $rec = array();
     if ($this->schema['cache'] > -1) {
         //每个表对应查询缓存的流水好,当该表的数据变更后,该流水号会递增,以便使其查询缓存失效
         $flow = $this->cache->get('qc.' . $this->mdl . '.' . $this->tbl, '0');
         $flow = $flow == '' ? '0' : $flow;
         $tid = 'gqc.' . md5($this->mdl . $this->tbl . serialize(array($filter, $page, $order)) . $flow);
         $rec = $this->cache->get($tid);
         if ($rec == '') {
             //未缓存命中
             $rec = $this->query($filter, $page, $order);
             $this->cache->set($tid, $rec);
         }
     } else {
         $rec = $this->query($filter, $page, $order);
     }
     return $rec;
 }
 /**
  * GET wrapper for TwitterOAuth
  */
 function get($url, $parameters = array())
 {
     return $this->TwitterOAuth->get($url, $parameters);
 }
示例#4
0
 /**
  * イベントスキップ判定
  * @param class $chatmessage 受信したメッセージのオブジェクト
  * @param string $chatmessage_id チャットメッセージID
  * @param string $property 「変化のあった」プロパティ
  * @param string $value 「変化のあった」値
  * @return bool true:スキップする, false:スキップしない
  */
 protected function isSkipEvent($chatmessage, $chatmessage_id, $property, $value)
 {
     if ($property != 'BODY' && $property != 'STATUS') {
         return true;
     }
     if ($property == 'STATUS' && ($value == Skype_Chatmessage::status_read || $value == Skype_Chatmessage::status_sending)) {
         return true;
     }
     if (false !== $this->config['plugin_ignore_edited_messages'] and '0' < $chatmessage->get('EDITED_TIMESTAMP')) {
         // 修正されたメッセージはスキップする
         return true;
     }
     if (false !== $this->config['plugin_ignore_self_messages'] and $chatmessage->get('FROM_HANDLE') === $this->skype->getCurrentUserHandle()) {
         // 自分自身のメッセージはスキップする
         return true;
     }
     return false;
 }