本文整理汇总了PHP中FileCache::load方法的典型用法代码示例。如果您正苦于以下问题:PHP FileCache::load方法的具体用法?PHP FileCache::load怎么用?PHP FileCache::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileCache
的用法示例。
在下文中一共展示了FileCache::load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* @param string $key
* @return mixed
* @throws KeyNotFoundException
*/
public function load($key)
{
if ($this->memoryCache->hasKey($key)) {
return $this->memoryCache->load($key);
} else {
if ($this->fileCache->hasKey($key)) {
return $this->fileCache->load($key);
}
}
throw new KeyNotFoundException();
}
示例2: cacher
/**
* Method, which control caching data before connect to MHD server
*/
private function cacher()
{
if (is_null($this->cache)) {
if (class_exists('Memcache') && $this->cacheType !== 'filecache') {
$this->cache = new MemoryCache();
} else {
$this->cache = new FileCache(dirname(__FILE__) . '/../cache/' . md5($this->link) . '.tmp');
}
}
if ($this->cacheType == 'filecache') {
$this->cache = new FileCache(dirname(__FILE__) . '/../cache/' . md5($this->link) . '.tmp');
}
$this->cache->load();
$cache_expire = $this->expire_time;
//seconds
if (!isset($this->cache->last_update) || !isset($this->cache->last_update['spoje']) || $this->cache->last_update['spoje'] + $cache_expire < time()) {
unset($this->cache->spoje);
}
if (!isset($this->cache->last_update) || !isset($this->cache->last_update['form_url']) || $this->cache->last_update['form_url'] + $cache_expire < time()) {
unset($this->cache->form_url);
}
if (isset($this->cache->last_update) && isset($this->cache->last_update['departures'])) {
foreach ($this->cache->last_update['departures'] as $spoj => $cas) {
if ($cas + $cache_expire < time()) {
unset($this->cache->departures[$spoj]);
unset($this->cache->categories[$spoj]);
}
}
} else {
unset($this->cache->departures[$spoj]);
unset($this->cache->categories[$spoj]);
}
if (isset($this->cache->last_update) && isset($this->cache->last_update['stops'])) {
foreach ($this->cache->last_update['stops'] as $spoj => $cas) {
if ($cas + $cache_expire < time()) {
unset($this->cache->stops[$spoj]);
}
}
} else {
unset($this->cache->stops[$spoj]);
}
if (isset($this->cache->stops)) {
$this->stops = $this->cache->stops;
}
if (isset($this->cache->departures)) {
$this->departures = $this->cache->departures;
}
if (isset($this->cache->spoje)) {
$this->spoje = $this->cache->spoje;
}
if (isset($this->cache->form_url)) {
$this->form_url = $this->cache->form_url;
}
if (isset($this->cache->categories)) {
$this->categories = $this->cache->categories;
}
self::online_map();
$this->checkedCache = true;
}
示例3: commentListGet
function commentListGet()
{
$cacheFile = new FileCache();
$cacheFile->load('commentlist.json');
if ($cacheFile->needUpdate()) {
return commentListGenerate();
} else {
return json_decode($cacheFile->read());
}
}
示例4: penListGet
function penListGet()
{
global $srkEnv;
$listCache = new FileCache();
$listCache->load('penlist.json');
if ($listCache->needUpdate()) {
return penListGenerate();
} else {
return json_decode($listCache->read());
}
}