/** * @return SplObjectStorage */ protected static function getCache() { if (!static::$cache) { static::$cache = new SplObjectStorage(); } return static::$cache; }
public function clearCache() { static::$cache = []; static::$cacheFile = NULL; $this->initialize(); return $this; }
public static function provide() { if (!static::$cache) { static::$cache = static::loadCache(); } return static::$cache; }
public function useRangeDate() { if (static::$cache === null) { static::$cache = $this->getHandleClassInstance(); } return static::$cache->useRangeDate(); }
/** * Get plugin config * * @param string $packageName * @param string $pluginName * @return Config */ public static function getConfig($packageName, $pluginName = null, $ignoreCache = false) { if (empty($packageName)) { throw new InvalidArgumentException("\$packageName is empty"); } if ($pluginName === null) { $pluginName = $packageName; } if (!is_object(static::$cache)) { static::$cache = new Config(); } if (isset(static::$globalConfig->{$packageName}) and isset(static::$globalConfig->{$packageName}->{$pluginName})) { $globalConfig = static::$globalConfig->{$packageName}->{$pluginName}; } else { $globalConfig = new Config(); } if (!$ignoreCache and isset(static::$cache->{$packageName}) and isset(static::$cache->{$packageName}->{$pluginName})) { return static::mergeConfigs($globalConfig, static::$cache->{$packageName}->{$pluginName}); } //echo "$packageName - $pluginName<br>\n"; if (file_exists(SITE_PACKAGES_PATH . "{$packageName}/{$pluginName}/DefaultConfig.inc.php")) { include SITE_PACKAGES_PATH . "{$packageName}/{$pluginName}/DefaultConfig.inc.php"; } elseif (file_exists(STINGLE_PATH . "packages/{$packageName}/{$pluginName}/DefaultConfig.inc.php")) { include STINGLE_PATH . "packages/{$packageName}/{$pluginName}/DefaultConfig.inc.php"; } else { $defaultConfig = array(); } $defaultConfigObj = new Config($defaultConfig); $result = static::mergeConfigs($globalConfig, $defaultConfigObj); if (!isset(static::$cache->{$packageName})) { static::$cache->{$packageName} = new Config(); } static::$cache->{$packageName}->{$pluginName} = $defaultConfigObj; return $result; }
/** * @return \metalguardian\fileProcessor\components\ThumbnailCache * @throws \yii\base\InvalidConfigException */ public static function cache() { if (is_null(static::$cache)) { static::$cache = \Yii::createObject(\metalguardian\fileProcessor\components\ThumbnailCache::className()); } return static::$cache; }
public static function setInstance($dir = null) { $dir = $dir ? $dir : "myAppDirCache"; static::$file_cache_dir = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . $dir; static::$cache = new sfFileCache(array('cache_dir' => static::$file_cache_dir)); return static::$cache; }
/** * Should be called in beforeRender() * */ public static function init(View $View) { $params = $View->request->params; if (Configure::read('UrlCache.pageFiles')) { $cachePageKey = '_misc'; if (is_object($View)) { $path = $View->request->here; if ($path === '/') { $path = 'uc_homepage'; } else { $path = strtolower(Inflector::slug($path)); } if (empty($path)) { $path = 'uc_error'; } $cachePageKey = '_' . $path; } static::$cachePageKey = static::$cacheKey . $cachePageKey; static::$cachePage = Cache::read(static::$cachePageKey, '_cake_core_'); } static::$cache = Cache::read(static::$cacheKey, '_cake_core_'); // still old "prefix true/false" syntax? if (Configure::read('UrlCache.verbosePrefixes')) { unset(static::$paramFields[3]); static::$paramFields = array_merge(static::$paramFields, (array) Configure::read('Routing.prefixes')); } static::$extras = array_intersect_key($params, array_combine(static::$paramFields, static::$paramFields)); $defaults = array(); foreach (static::$paramFields as $field) { $defaults[$field] = ''; } static::$extras = array_merge($defaults, static::$extras); }
/** * Use a custom fCache object to serve caches. Any fCache object works, so if the directory * cache isn't working well, developers should test different cache options and find one that * works best. * * @param fCache $cache The fCache object to serve as a cache */ public static function setCustomCache(fCache $cache) { if (static::$authorized_override) { return false; } static::$enabled = true; static::$cache = $cache; }
public static function request() { if (empty(self::$cache)) { static::$cache = new \Rpp\Extend\Memcached(); return static::$cache; } else { return static::$cache; } }
/** * Load annotation cache strategy * * @param CacheInterface $cache * @return CacheInterface */ public static function cache(CacheInterface $cache = null) { if ($cache) { static::$cache = $cache; } elseif (!static::$cache) { static::$cache = new Annotation\EphemeralCache(); } return static::$cache; }
public static function setUpBeforeClass() { if (!extension_loaded('xcache')) { static::$cache = null; return; } xcache_clear_cache(XC_TYPE_VAR); static::$cache = new \Cachalot\XcacheCache('cachalot-test:'); }
public static function setUpBeforeClass() { if (!extension_loaded('apc') && !extension_loaded('apcu')) { static::$cache = null; return; } apc_clear_cache(); static::$cache = new \Cachalot\ApcCache('cachalot-test:'); }
public static function setUpBeforeClass() { if (!extension_loaded('couchbase') || !class_exists('CouchbaseCluster')) { static::$cache = null; return; } $cluster = new \CouchbaseCluster('couchbase://localhost'); $bucket = $cluster->openBucket('cachalot-test'); static::$cache = new \Cachalot\Couchbase2Cache($bucket); }
public static function setUpBeforeClass() { if (!extension_loaded('couchbase') || !class_exists('Couchbase')) { static::$cache = null; return; } $couchbase = new \Couchbase('127.0.0.1', '', '', 'cachalot-test'); $couchbase->flush(); static::$cache = new \Cachalot\CouchbaseCache($couchbase); }
public static function setUpBeforeClass() { if (!extension_loaded('memcached')) { static::$cache = null; return; } $memcached = new \Memcached(); $memcached->addServer('/usr/local/var/run/memcached.sock', 0); $memcached->flush(); static::$cache = new \Cachalot\MemcachedCache($memcached, 'cachalot-test:'); }
public static function request() { if (empty(self::$cache)) { $redis = new \Redis(); $redis->connect(static::get_conf()->redis->host, static::get_conf()->redis->port); static::$cache = $redis; return static::$cache; } else { return static::$cache; } }
public static function cacheLoad() { if (array() === static::$cache) { static::$cache = APC::get('classes', array()); register_shutdown_function(function () { if (Vendors::$cacheChanged) { APC::put('classes', Vendors::$cache); } }); } }
public function __construct() { static::$cache = new \Memcached(); static::$cone_status = static::$cache->addServer(static::get_conf()->memcache->host, static::get_conf()->memcache->port); $this->prefix = static::get_conf()->memcache->prefix; //static::$cache = new \Memcached(); //static::$cache->setOption(Memcached::OPT_CLIENT_MODE, Memcached::DYNAMIC_CLIENT_MODE); //static::$cache->setOption(Memcached::OPT_COMPRESSION, true); //static::$cone_status = static::$cache->addServer(static::get_conf()->memcache->host, static::get_conf()->memcache->port); //$this->prefix = static::get_conf()->memcache->prefix; }
public static function setUpBeforeClass() { if (!extension_loaded('memcache')) { static::$cache = null; return; } $memcache = new \Memcache(); $memcache->connect('unix:///usr/local/var/run/memcached.sock', 0); $memcache->flush(); static::$cache = new \Cachalot\MemcacheCache($memcache, 'cachalot-test:'); }
public static function request() { if (empty(self::$cache)) { $frontCache = new \Phalcon\Cache\Frontend\Data(array("lifetime" => static::get_conf()->memcache->lifetime)); static::$cache = new \Rpp\Extend\Publish\Memcache($frontCache, array("host" => static::get_conf()->memcache->host, "port" => static::get_conf()->memcache->port, "prefix" => static::get_conf()->memcache->prefix, "statsKey" => static::get_conf()->memcache->stats)); static::$cache->localconnect(); return static::$cache; } else { return static::$cache; } }
public static function setUpBeforeClass() { if (!extension_loaded('redis')) { static::$cache = null; return; } $redis = new \Redis(); $redis->connect('127.0.0.1'); $redis->select(1); $redis->flushAll(); static::$cache = new \Cachalot\RedisCache($redis, 'cachalot-test:'); }
/** * Finds a Class. * * @return object * * @throws NotFoundException */ public static function find() { // We have a cache if (isset(static::$cache)) { return new static::$cache(); } foreach (static::$classes as $name => $definition) { if (static::evaluateCondition($definition['condition'])) { static::$cache = $definition['class']; return new $definition['class'](); } } throw new NotFoundException('Not found'); }
/** * @param ContainerInterface $container * @return \Thelia\ImportExport\Export\ExportHandler * @throws \ErrorException */ public function getHandleClassInstance(ContainerInterface $container) { $class = $this->getHandleClass(); if ($class[0] !== "\\") { $class = "\\" . $class; } if (!class_exists($class)) { $this->delete(); throw new \ErrorException(Translator::getInstance()->trans("The class \"%class\" doesn't exist", ["%class" => $class])); } $instance = new $class($container); if (!$instance instanceof ExportHandler) { $this->delete(); throw new \ErrorException(Translator::getInstance()->trans("The class \"%class\" must extend %baseClass", ["%class" => $class, "%baseClass" => "Thelia\\ImportExport\\Export\\ExportHandler"])); } return static::$cache = $instance; }
public function __construct($config) { static::$config = $config; static::$request = $this->request(); static::$cache = new Cache(); $this->connection = static::connect(); if (isset($_REQUEST['upgrade'])) { $this->checkDBVersion(); } if (isset($_REQUEST['cssbump'])) { $this->setOption('cssv', time()); } if (rand(0, 100) <= 10) { Auth::cleanSessions(); } // 10% chance; should be moved to a cron job }
/** * find implementations for a specific interface or classes extending from base class * @param string $interfaceName full class/interface name to look implementations up for * @param boolean $forceRecache * @param string $cacheFile */ public static function getImplementations($interfaceName, $forceRecache = FALSE, $cacheFile = NULL) { $vendorDir = realpath(__DIR__ . '/../../../'); static::$rootDirectory = realpath(__DIR__ . '/../../../../') . '/'; static::locateComposerPaths(); if (static::$cache === NULL) { if (static::$cacheFile === NULL) { $md5 = static::generateCacheHash(); static::$cacheFile = sys_get_temp_dir() . '/class_register_' . $md5 . '.php'; } if (file_exists(static::$cacheFile) && $forceRecache === FALSE) { static::$cache = (include static::$cacheFile); } else { static::$cache = static::generateCache(static::$cacheFile); } } return isset(static::$cache[$interfaceName]) ? static::$cache[$interfaceName] : array(); }
/** * Load * @param $basePath * @param bool|false $enableCache * @param array $options */ public static function load($basePath, $enableCache = false, $options = []) { static::$basePath = $basePath; static::$configPath = __DIR__ . '/config'; static::$appConfigPath = static::$basePath . '/' . static::$configDir; static::$enableCache = $enableCache; if ($options && $options['cacheDuration']) { static::$cacheDuration = (int) $options['cacheDuration']; } if ($options && $options['cacheDir']) { static::$cacheDir = (string) $options['cacheDir']; } if (static::$enableCache) { static::$cache = new FileCache(['cachePath' => $basePath . '/' . static::$cacheDir]); } if (!is_dir(static::$appConfigPath)) { \yii\helpers\FileHelper::createDirectory(static::$appConfigPath); } static::loadMainConfig(); }
public function visit(Node $node) { if (static::$cache === NULL) { static::$cache = []; $ref = new \ReflectionClass(static::class); foreach ($ref->getMethods() as $method) { if ($method->isStatic() || !preg_match("'^visit\\w'i", $method->name)) { continue; } $param = $method->getParameters()[0] ?? NULL; if ($param !== NULL) { $type = $param->getClass(); if ($type !== NULL) { static::$cache[$type->name] = $method->name; } } } } $key = get_class($node); if (isset(static::$cache[$key])) { return $this->{static::$cache[$key]}($node); } }
/** * Set cache * @param Cache $cache */ public static function cache($cache) { static::$cache = $cache; }
/** * Reset class state to defaults * * @return void */ public static function reset() { static::$cache = null; static::$httpClient = null; static::$httpMethodOverride = false; static::$httpConditionalGet = false; static::$extensionManager = null; static::$extensions = array('feed' => array('DublinCore\\Feed', 'Atom\\Feed'), 'entry' => array('Content\\Entry', 'DublinCore\\Entry', 'Atom\\Entry'), 'core' => array('DublinCore\\Feed', 'Atom\\Feed', 'Content\\Entry', 'DublinCore\\Entry', 'Atom\\Entry')); }