當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Memcache::limitquery方法代碼示例

本文整理匯總了PHP中Memcache::limitquery方法的典型用法代碼示例。如果您正苦於以下問題:PHP Memcache::limitquery方法的具體用法?PHP Memcache::limitquery怎麽用?PHP Memcache::limitquery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Memcache的用法示例。


在下文中一共展示了Memcache::limitquery方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: read_record

 /**
  * Reads cache entry.
  *
  * @param string  $key     Cache key name
  * @param boolean $nostore Enable to skip in-memory store
  *
  * @return mixed Cached value
  */
 private function read_record($key, $nostore = false)
 {
     if (!$this->db) {
         return null;
     }
     if ($this->type != 'db') {
         $this->load_index();
         // Consistency check (#1490390)
         if (!in_array($key, $this->index)) {
             // we always check if the key exist in the index
             // to have data in consistent state. Keeping the index consistent
             // is needed for keys delete operation when we delete all keys or by prefix.
         } else {
             $ckey = $this->ckey($key);
             if ($this->type == 'memcache') {
                 $data = $this->db->get($ckey);
             } else {
                 if ($this->type == 'apc') {
                     $data = apc_fetch($ckey);
                 }
             }
             if ($this->debug) {
                 $this->debug('get', $ckey, $data);
             }
         }
         if ($data) {
             $md5sum = md5($data);
             $data = $this->unserialize($data);
             if ($nostore) {
                 return $data;
             }
             $this->cache_sums[$key] = $md5sum;
             $this->cache[$key] = $data;
         } else {
             $this->cache[$key] = null;
         }
     } else {
         $sql_result = $this->db->limitquery("SELECT `data`, `cache_key`" . " FROM {$this->table}" . " WHERE `user_id` = ? AND `cache_key` = ?" . " ORDER BY `created` DESC", 0, 1, $this->userid, $this->prefix . '.' . $key);
         if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
             $key = substr($sql_arr['cache_key'], strlen($this->prefix) + 1);
             $md5sum = $sql_arr['data'] ? md5($sql_arr['data']) : null;
             if ($sql_arr['data']) {
                 $data = $this->unserialize($sql_arr['data']);
             }
             if ($nostore) {
                 return $data;
             }
             $this->cache[$key] = $data;
             $this->cache_sums[$key] = $md5sum;
         } else {
             $this->cache[$key] = null;
         }
     }
     return $this->cache[$key];
 }
開發者ID:JotapePinheiro,項目名稱:roundcubemail,代碼行數:63,代碼來源:rcube_cache.php

示例2: read_record

 /**
  * Reads cache entry.
  *
  * @param string  $key     Cache key name
  * @param boolean $nostore Enable to skip in-memory store
  *
  * @return mixed Cached value
  */
 private function read_record($key, $nostore = false)
 {
     if (!$this->db) {
         return null;
     }
     if ($this->type != 'db') {
         if ($this->type == 'memcache') {
             $data = $this->db->get($this->ckey($key));
         } else {
             if ($this->type == 'apc') {
                 $data = apc_fetch($this->ckey($key));
             }
         }
         if ($data) {
             $md5sum = md5($data);
             $data = $this->unserialize($data);
             if ($nostore) {
                 return $data;
             }
             $this->cache_sums[$key] = $md5sum;
             $this->cache[$key] = $data;
         } else {
             $this->cache[$key] = null;
         }
     } else {
         $sql_result = $this->db->limitquery("SELECT data, cache_key" . " FROM " . $this->table . " WHERE user_id = ?" . " AND cache_key = ?" . " ORDER BY created DESC", 0, 1, $this->userid, $this->prefix . '.' . $key);
         if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
             $key = substr($sql_arr['cache_key'], strlen($this->prefix) + 1);
             $md5sum = $sql_arr['data'] ? md5($sql_arr['data']) : null;
             if ($sql_arr['data']) {
                 $data = $this->unserialize($sql_arr['data']);
             }
             if ($nostore) {
                 return $data;
             }
             $this->cache[$key] = $data;
             $this->cache_sums[$key] = $md5sum;
         } else {
             $this->cache[$key] = null;
         }
     }
     return $this->cache[$key];
 }
開發者ID:bbspike,項目名稱:sentora-core,代碼行數:51,代碼來源:rcube_cache.php

示例3: read_record

 /**
  * Reads cache entry.
  *
  * @param string  $key     Cache key name
  * @param boolean $nostore Enable to skip in-memory store
  *
  * @return mixed Cached value
  */
 private function read_record($key, $nostore = false)
 {
     if (!$this->db) {
         return null;
     }
     if ($this->type != 'db') {
         if ($this->type == 'memcache') {
             $data = $this->db->get($this->ckey($key));
         } else {
             if ($this->type == 'apc') {
                 $data = apc_fetch($this->ckey($key));
             }
         }
         if ($data) {
             $md5sum = md5($data);
             $data = $this->unserialize($data);
             if ($nostore) {
                 return $data;
             }
             $this->cache_sums[$key] = $md5sum;
             $this->cache[$key] = $data;
         } else {
             $this->cache[$key] = null;
         }
     } else {
         $sql_result = $this->db->limitquery("SELECT `data`, `cache_key`" . " FROM {$this->table}" . " WHERE `cache_key` = ?" . " ORDER BY `created` DESC", 0, 1, $this->prefix . '.' . $key);
         if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
             $md5sum = $sql_arr['data'] ? md5($sql_arr['data']) : null;
             if ($sql_arr['data']) {
                 $data = $this->unserialize($sql_arr['data']);
             }
             if ($nostore) {
                 return $data;
             }
             $this->cache[$key] = $data;
             $this->cache_sums[$key] = $md5sum;
         } else {
             $this->cache[$key] = null;
         }
     }
     return $this->cache[$key];
 }
開發者ID:StudsPro,項目名稱:islandpeeps.com,代碼行數:50,代碼來源:rcube_cache_shared.php


注:本文中的Memcache::limitquery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。