本文整理匯總了PHP中GO::_cache方法的典型用法代碼示例。如果您正苦於以下問題:PHP GO::_cache方法的具體用法?PHP GO::_cache怎麽用?PHP GO::_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GO
的用法示例。
在下文中一共展示了GO::_cache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: cache
/**
* Returns cache driver. Cached items will persist between connections and are
* available to all users. When debug is enabled a dummy cache driver is used
* that caches nothing.
*
* @return \GO\Base\Cache\CacheInterface
*/
public static function cache()
{
if (!isset(self::$_cache)) {
if (GO::config()->debug || !GO::isInstalled()) {
self::$_cache = new \GO\Base\Cache\None();
} else {
if (!isset(GO::session()->values['cacheDriver'])) {
$cachePref = array("\\GO\\Base\\Cache\\Apc", "\\GO\\Base\\Cache\\Disk");
foreach ($cachePref as $cacheDriver) {
$cache = new $cacheDriver();
if ($cache->supported()) {
GO::debug("Using {$cacheDriver} cache");
GO::session()->values['cacheDriver'] = $cacheDriver;
self::$_cache = $cache;
break;
}
}
} else {
$cacheDriver = GO::session()->values['cacheDriver'];
self::$_cache = new $cacheDriver();
}
}
}
return self::$_cache;
}