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


PHP Cache::checkCallbacks方法代碼示例

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


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

示例1: read

 /**
  * Read from cache.
  * @param  string key
  * @return mixed|NULL
  */
 public function read($key)
 {
     $key = $this->prefix . $key;
     $meta = $this->memcache->get($key);
     if (!$meta) {
         return NULL;
     }
     // meta structure:
     // array(
     //     data => stored data
     //     delta => relative (sliding) expiration
     //     callbacks => array of callbacks (function, args)
     // )
     // verify dependencies
     if (!empty($meta[self::META_CALLBACKS]) && !Cache::checkCallbacks($meta[self::META_CALLBACKS])) {
         $this->memcache->delete($key, 0);
         return NULL;
     }
     if (!empty($meta[self::META_DELTA])) {
         $this->memcache->replace($key, $meta, 0, $meta[self::META_DELTA] + time());
     }
     return $meta[self::META_DATA];
 }
開發者ID:cujan,項目名稱:atlashornin,代碼行數:28,代碼來源:MemcachedStorage.php

示例2: read

 /**
  * Read from cache.
  * @param  string key
  * @return mixed|NULL
  */
 public function read($key)
 {
     $this->_normalizeKey($key);
     $meta = apc_fetch($key);
     if (!$meta) {
         return NULL;
     }
     // meta structure:
     // array(
     //     data => stored data
     //     delta => relative (sliding) expiration
     //     callbacks => array of callbacks (function, args)
     // )
     // verify dependencies
     if (!empty($meta[self::META_CALLBACKS]) && !Cache::checkCallbacks($meta[self::META_CALLBACKS])) {
         apc_delete($key);
         return NULL;
     }
     if (!empty($meta[self::META_DELTA])) {
         apc_delete($key);
         apc_store($key, $meta, 0, $meta[self::META_DELTA] + time());
     }
     return $meta[self::META_DATA];
 }
開發者ID:svobodni,項目名稱:web,代碼行數:29,代碼來源:ApcStorage.php

示例3: verify

 /**
  * Verifies dependencies.
  * @param  array
  * @return bool
  */
 private function verify($meta)
 {
     do {
         if (!empty($meta[self::META_DELTA])) {
             // meta[file] was added by readMetaAndLock()
             if (filemtime($meta[self::FILE]) + $meta[self::META_DELTA] < time()) {
                 break;
             }
             touch($meta[self::FILE]);
         } elseif (!empty($meta[self::META_EXPIRE]) && $meta[self::META_EXPIRE] < time()) {
             break;
         }
         if (!empty($meta[self::META_CALLBACKS]) && !Cache::checkCallbacks($meta[self::META_CALLBACKS])) {
             break;
         }
         if (!empty($meta[self::META_ITEMS])) {
             foreach ($meta[self::META_ITEMS] as $depFile => $time) {
                 $m = $this->readMetaAndLock($depFile, LOCK_SH);
                 if ($m[self::META_TIME] !== $time || $m && !$this->verify($m)) {
                     break 2;
                 }
             }
         }
         return TRUE;
     } while (FALSE);
     $this->delete($meta[self::FILE], $meta[self::HANDLE]);
     // meta[handle] & meta[file] was added by readMetaAndLock()
     return FALSE;
 }
開發者ID:nette,項目名稱:caching,代碼行數:34,代碼來源:FileStorage.php

示例4: read

 function read($key)
 {
     $key = $this->prefix . $key;
     $meta = $this->memcache->get($key);
     if (!$meta) {
         return NULL;
     }
     if (!empty($meta[self::META_CALLBACKS]) && !Cache::checkCallbacks($meta[self::META_CALLBACKS])) {
         $this->memcache->delete($key, 0);
         return NULL;
     }
     if (!empty($meta[self::META_DELTA])) {
         $this->memcache->replace($key, $meta, 0, $meta[self::META_DELTA] + time());
     }
     return $meta[self::META_DATA];
 }
開發者ID:rotten77,項目名稱:xcv,代碼行數:16,代碼來源:nette.min.php

示例5: verify

 /**
  * Verifies dependencies.
  *
  * @param  array
  *
  * @return bool
  */
 protected function verify($meta)
 {
     do {
         if (!empty($meta[self::META_DELTA])) {
             $this->client->send('expire', [$this->formatEntryKey($meta[self::KEY]), $meta[self::META_DELTA]]);
         } elseif (!empty($meta[self::META_EXPIRE]) && $meta[self::META_EXPIRE] < time()) {
             break;
         }
         if (!empty($meta[self::META_CALLBACKS]) && !Cache::checkCallbacks($meta[self::META_CALLBACKS])) {
             break;
         }
         if (!empty($meta[self::META_ITEMS])) {
             foreach ($meta[self::META_ITEMS] as $itemKey => $time) {
                 $m = $this->readMeta($itemKey);
                 if ($m[self::META_TIME] !== $time || $m && !$this->verify($m)) {
                     break 2;
                 }
             }
         }
         return TRUE;
     } while (FALSE);
     $this->remove($meta[self::KEY]);
     // meta[handle] & meta[file] was added by readMetaAndLock()
     return FALSE;
 }
開發者ID:kdyby,項目名稱:redis,代碼行數:32,代碼來源:RedisStorage.php

示例6: bulkRead

 /**
  * Reads from cache in bulk.
  * @param  string key
  * @return array key => value pairs, missing items are omitted
  */
 public function bulkRead(array $keys)
 {
     $prefixedKeys = array_map(function ($key) {
         return urlencode($this->prefix . $key);
     }, $keys);
     $keys = array_combine($prefixedKeys, $keys);
     $metas = $this->memcached->getMulti($prefixedKeys);
     $result = [];
     $deleteKeys = [];
     foreach ($metas as $prefixedKey => $meta) {
         if (!empty($meta[self::META_CALLBACKS]) && !Cache::checkCallbacks($meta[self::META_CALLBACKS])) {
             $deleteKeys[] = $prefixedKey;
         } else {
             $result[$keys[$prefixedKey]] = $meta[self::META_DATA];
         }
         if (!empty($meta[self::META_DELTA])) {
             $this->memcached->replace($prefixedKey, $meta, $meta[self::META_DELTA] + time());
         }
     }
     if (!empty($deleteKeys)) {
         $this->memcached->deleteMulti($deleteKeys, 0);
     }
     return $result;
 }
開發者ID:nette,項目名稱:caching,代碼行數:29,代碼來源:NewMemcachedStorage.php


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