Ejemplo n.º 1
0
 /**
  * 
  * @staticvar null $cacheSettings
  * @staticvar null $defaultStorageName
  * @param type $storageName
  * @return \Floxim\Cache\Storage\AbstractStorage;
  */
 public static function cache($storageName = null)
 {
     static $cacheSettings = null;
     static $defaultStorageName = null;
     if (is_null(self::$cache)) {
         $cacheSettings = fx::config('cache.data.storages');
         $defaultStorageName = fx::config('cache.data.default_storage');
         self::$cache = new \Floxim\Cache\Manager();
         self::$cache->setKeyPrefix(fx::config('cache.data.default_prefix'));
         // setup default storage
         $defaultStorage = self::$cache->getStorage($defaultStorageName, $cacheSettings[$defaultStorageName]);
         self::$cache->setDefaultStorage($defaultStorage);
     }
     if (is_null($storageName)) {
         $storageName = $defaultStorageName;
     }
     $params = isset($cacheSettings[$storageName]) ? $cacheSettings[$storageName] : array();
     return self::$cache->getStorage($storageName, $params);
 }