Exemple #1
0
 /**
  * Factory for cache implementations.
  *
  * @param array $options Cache options.
  *
  * @throws CacheException
  * @return ICache
  */
 private static function _returnCacheFromImpl($options)
 {
     switch ($options['impl']) {
         case 'file':
             return FileCacheImpl::getInstance($options);
         case 'apc':
             return ApcCacheImpl::getInstance($options);
         case 'dummy':
             return DummyCacheImpl::getInstance($options);
         case 'zend':
             return ZendCacheImpl::getInstance($options['zend']);
         case 'memcached':
             return MemcachedCacheImpl::getInstance($options['memcached']);
         default:
             throw new CacheException('Invalid cache impl requested');
     }
 }
Exemple #2
0
 /**
  * Returns an instance of a cache.
  *
  * @param array $options Options for the cache backend.
  *
  * @return DummyCacheImpl
  */
 public static function getInstance($options = array())
 {
     $dir = $options['directory'];
     if (!isset(self::$_instances[$dir])) {
         $ret = new FileCacheImpl($options);
         self::$_instances[$dir] = $ret;
         $ret->_init();
     } else {
         $ret = self::$_instances[$dir];
     }
     return $ret;
 }