当前位置: 首页>>代码示例>>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;未经允许,请勿转载。