Exemple #1
0
 /**
  * Getter for Cache instance
  * Creates instance if called for the first time
  * Creates MemcachedStorage if extension memcache exists
  * Otherwise FileStorage Cache is created
  * Triggers notice if config variable advertisememcached in perform block is not set to false
  * @return Cache
  */
 public static function getCache()
 {
     if (!self::$cache) {
         $config = Environment::getConfig('perform');
         if (extension_loaded('memcache')) {
             self::$cache = new Cache(new MemcachedStorage($config->memcache_host, $config->memcache_port, $config->cache_prefix));
             $namespace = self::$cache;
             $namespace['test'] = true;
             if ($namespace['test'] === true) {
                 return self::$cache;
             }
         }
         self::$cache = Environment::getCache($config->cache_prefix);
         if ($config->advertisememcached) {
             trigger_error("FileCache enabled, use Memcached if possible. Turn off this warning by setting advertisememcached to false", E_USER_WARNING);
         }
     }
     return self::$cache;
 }