本文整理汇总了PHP中wfConfig::diskCacheDisabled方法的典型用法代码示例。如果您正苦于以下问题:PHP wfConfig::diskCacheDisabled方法的具体用法?PHP wfConfig::diskCacheDisabled怎么用?PHP wfConfig::diskCacheDisabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfConfig
的用法示例。
在下文中一共展示了wfConfig::diskCacheDisabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFromDiskCache
public static function loadFromDiskCache($key)
{
if (!self::$diskCacheDisabled) {
if (isset(wfConfig::$diskCache[$key])) {
return wfConfig::$diskCache[$key];
}
$cacheFile = self::getCacheFile();
if (is_file($cacheFile)) {
//require($cacheFile); //will only require the file on first parse through this code. But we dynamically update the var and update the file with each get
try {
$cont = @file_get_contents($cacheFile);
if (strpos($cont, '<?php') === 0) {
//"<?php die() XX"
$cont = substr($cont, strlen(self::$tmpFileHeader));
wfConfig::$diskCache = @unserialize($cont);
if (isset(wfConfig::$diskCache) && is_array(wfConfig::$diskCache) && isset(wfConfig::$diskCache[$key])) {
return wfConfig::$diskCache[$key];
}
}
//Else don't return a cached value because this is an old file without the php header so we're going to rewrite it.
} catch (Exception $err) {
}
//file_get or unserialize may fail, so just fail quietly.
}
}
$val = self::getDB()->querySingle("select val from " . self::table() . " where name='%s'", $key);
if (self::$diskCacheDisabled) {
return $val;
}
wfConfig::$diskCache[$key] = isset($val) ? $val : '';
try {
$bytesWritten = @file_put_contents($cacheFile, self::$tmpFileHeader . serialize(wfConfig::$diskCache), LOCK_EX);
} catch (Exception $err2) {
}
if (!$bytesWritten) {
self::$diskCacheDisabled = true;
}
return $val;
}
示例2: loadFromDiskCache
public static function loadFromDiskCache($key)
{
if (!self::$diskCacheDisabled) {
if (isset(wfConfig::$diskCache[$key])) {
return wfConfig::$diskCache[$key];
}
$cacheFile = self::getCacheFile();
if (is_file($cacheFile)) {
//require($cacheFile); //will only require the file on first parse through this code. But we dynamically update the var and update the file with each get
try {
wfConfig::$diskCache = @unserialize(@file_get_contents($cacheFile));
if (isset(wfConfig::$diskCache) && is_array(wfConfig::$diskCache) && isset(wfConfig::$diskCache[$key])) {
return wfConfig::$diskCache[$key];
}
} catch (Exception $err) {
}
//file_get or unserialize may fail, so just fail quietly.
}
}
$val = self::getDB()->querySingle("select val from " . self::table() . " where name='%s'", $key);
if (self::$diskCacheDisabled) {
return $val;
}
wfConfig::$diskCache[$key] = isset($val) ? $val : '';
try {
$bytesWritten = @file_put_contents($cacheFile, serialize(wfConfig::$diskCache), LOCK_EX);
} catch (Exception $err2) {
}
if (!$bytesWritten) {
self::$diskCacheDisabled = true;
}
return $val;
}