Example #1
0
 /**
  * @return SplObjectStorage
  */
 protected static function getCache()
 {
     if (!static::$cache) {
         static::$cache = new SplObjectStorage();
     }
     return static::$cache;
 }
Example #2
0
 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;
 }
Example #4
0
 public function useRangeDate()
 {
     if (static::$cache === null) {
         static::$cache = $this->getHandleClassInstance();
     }
     return static::$cache->useRangeDate();
 }
Example #5
0
 /**
  * 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;
 }
Example #7
0
 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;
 }
Example #8
0
 /**
  * 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);
 }
Example #9
0
 /**
  * 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;
 }
Example #10
0
 public static function request()
 {
     if (empty(self::$cache)) {
         static::$cache = new \Rpp\Extend\Memcached();
         return static::$cache;
     } else {
         return static::$cache;
     }
 }
Example #11
0
 /**
  * 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;
 }
Example #12
0
 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:');
 }
Example #13
0
 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:');
 }
Example #14
0
 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);
 }
Example #15
0
 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);
 }
Example #16
0
 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:');
 }
Example #17
0
 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;
     }
 }
Example #18
0
 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);
             }
         });
     }
 }
Example #19
0
 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;
 }
Example #20
0
 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:');
 }
Example #21
0
 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;
     }
 }
Example #22
0
 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:');
 }
Example #23
0
 /**
  * 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');
 }
Example #24
0
 /**
  * @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;
 }
Example #25
0
 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
 }
Example #26
0
 /**
  * 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();
 }
Example #28
0
 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);
     }
 }
Example #29
0
File: Alias.php Project: yunaid/yf
 /**
  * Set cache
  * @param Cache $cache
  */
 public static function cache($cache)
 {
     static::$cache = $cache;
 }
Example #30
0
 /**
  * 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'));
 }