Ejemplo n.º 1
0
 public function testPluginFactory()
 {
     $plugin1 = Cache\StorageFactory::pluginFactory('Serializer');
     $this->assertInstanceOf('Zend\\Cache\\Storage\\Plugin\\Serializer', $plugin1);
     $plugin2 = Cache\StorageFactory::pluginFactory('Serializer');
     $this->assertInstanceOf('Zend\\Cache\\Storage\\Plugin\\Serializer', $plugin2);
     $this->assertNotSame($plugin1, $plugin2);
 }
Ejemplo n.º 2
0
 /**
  * Setup APC cache
  * @return Zend\Cache\Manager
  */
 public function _initCache()
 {
     $container = $this;
     $this['cacheManager'] = $this->share(function () use($container) {
         $cacheConfigs = $container['configs']['cache'];
         switch ($cacheConfigs['storage']) {
             case 'apc':
                 $cache = StorageFactory::adapterFactory('apc', ['ttl' => $cacheConfigs['ttl']]);
                 break;
             case 'memcached':
                 $cache = StorageFactory::adapterFactory('memcached', ['ttl' => $cacheConfigs['ttl']]);
                 break;
             default:
                 $cache = StorageFactory::adapterFactory('filesystem', ['ttl' => $cacheConfigs['ttl'], 'cache_dir' => CACHE_DIR . '/sessions']);
                 break;
         }
         $plugin = StorageFactory::pluginFactory('exception_handler', ['throw_exceptions' => true]);
         $cache->addPlugin($plugin);
         return $cache;
     });
 }