public static function initialize($ForceEnable = false, $ForceMethod = false)
{
$AllowCaching = self::activeEnabled($ForceEnable);
$ActiveCache = Gdn_Cache::activeCache();
if ($ForceMethod !== false) {
$ActiveCache = $ForceMethod;
}
$ActiveCacheClass = 'Gdn_' . ucfirst($ActiveCache);
if (!$AllowCaching || !$ActiveCache || !class_exists($ActiveCacheClass)) {
$CacheObject = new Gdn_Dirtycache();
} else {
$CacheObject = new $ActiveCacheClass();
}
// Null caches should not acount as enabled.
if (!$ForceEnable && $CacheObject->type() === Gdn_Cache::CACHE_TYPE_NULL) {
SaveToConfig('Cache.Enabled', false, false);
}
if (method_exists($CacheObject, 'Autorun')) {
$CacheObject->autorun();
}
// This should only fire when cache is loading automatically
if (!func_num_args() && Gdn::pluginManager() instanceof Gdn_PluginManager) {
Gdn::pluginManager()->fireEvent('AfterActiveCache');
}
return $CacheObject;
}