public function setUp() { $this->_originaltimezone = date_default_timezone_get(); date_default_timezone_set('Europe/Paris'); $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); DateObjectTestHelper::setOptions(array('cache' => $this->_cache)); }
public function getServiceConfig() { return ['factories' => ['Cache' => function ($sm) { // Trabalhando com APC $config = $sm->get('Config'); $cache = StorageFactory::factory(['adapter' => ['name' => $config['cache']['adapter'], 'options' => ['ttl' => $config['cache']['ttl']]], 'plugins' => ['Serializer', 'exception_handler' => ['throw_exceptions' => $config['cache']['throw_exceptions']]]]); return $cache; /* Trabalhando com memcached $factory = [ 'adapter' => [ 'name' => 'Memcached', 'options' => [ 'ttl' => 10, 'servers' => [ ['127.0.0.1', 11211] ] ], ], 'plugins' => [ 'Serializer', 'exception_handler' => ['throw_exceptions' => true],// em produção false ], ]; $cache = StorageFactory::factory($factory); return $cache; */ }]]; }
public function setUp() { $this->_originaltimezone = date_default_timezone_get(); date_default_timezone_set('Europe/Paris'); $this->_cache = CacheFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => array('ttl' => 120)), 'plugins' => array(array('name' => 'serializer', 'options' => array('serializer' => 'php_serialize'))))); DateObjectTestHelper::setOptions(array('cache' => $this->_cache)); }
/** * Return the sed Cache adapter. * * @return mixed|StorageInterface */ public function getCacheAdapter() { if (null == $this->storageAdapter) { $this->storageAdapter = StorageFactory::factory($this->options['cache']); } return $this->storageAdapter; }
public function registerFactories() { $this->createFactoryObject("Zend\\Cache\\Storage\\Adapter\\Memcached", function () { $memcached = $this->configManager->getMemcached(); return StorageFactory::factory(array('adapter' => array('name' => 'memcached', 'options' => array('servers' => array(array($memcached['Host'], $memcached['Port'])))))); }); }
public function setup() { $sl = bootstrap::getServiceManager(); $this->sitemap = $sl->get('NetgluePrismic\\Service\\Sitemap'); $this->cache = StorageFactory::factory(array('adapter' => 'apc', 'options' => array())); $this->cache->flush(); }
public function setUp() { $this->storage = StorageFactory::factory(array('adapter' => 'apc', 'options' => array())); $this->storage->flush(); $services = bootstrap::getServiceManager(); $services->setAllowOverride(true); }
/** * @param array $configuration * @throws \Zend\Cache\Exception\InvalidArgumentException * @throws \Zend\Cache\Exception\RuntimeException */ public function __construct(array $configuration) { if (!isset($configuration['adapter'])) { $configuration['adapter'] = 'Filesystem'; } if (!isset($configuration['adapterOptions'])) { $configuration['adapterOptions'] = []; } $cache = StorageFactory::factory(['adapter' => ['name' => $configuration['adapter'], 'options' => $configuration['adapterOptions']]]); $options = $cache->getOptions(); $options->setNamespace('Shariff'); $options->setTtl($configuration['ttl']); if ($options instanceof FilesystemOptions) { $options->setCacheDir(isset($configuration['cacheDir']) ? $configuration['cacheDir'] : sys_get_temp_dir()); } if ($cache instanceof ClearExpiredInterface) { if (function_exists('register_postsend_function')) { // for hhvm installations: executing after response / session close register_postsend_function(function () use($cache) { $cache->clearExpired(); }); } else { // default $cache->clearExpired(); } } $this->cache = $cache; }
public function getServiceConfig() { return array('factories' => array('MajesticExternalForms\\Models\\MajesticExternalFormsModel' => function ($sm) { $model_forms = new MajesticExternalFormsModel(); return $model_forms; }, 'MajesticExternalForms\\Events\\MajesticExternalFormsEvents' => function ($sm) { $events_external_forms = new MajesticExternalFormsEvents(); return $events_external_forms; }, 'MajesticExternalForms\\Models\\MajesticExternalFormsCacheModel' => function ($sm) { $arr_config = $sm->get("config"); try { $cache = StorageFactory::factory($arr_config["cache_redis_config_common"]); } catch (\Exception $e) { $dir = "./data/cache/external_forms"; if (!is_dir("./data/cache/external_forms")) { mkdir($dir, 0777, TRUE); } //end if //try local file system try { $arr_cache_config = $arr_config["cache_filesystem_config_common"]; $arr_cache_config["adapter"]["options"]["cache_dir"] = $dir; $cache = StorageFactory::factory($arr_cache_config); } catch (\Exception $e) { throw new \Exception(__CLASS__ . " Line " . __LINE__ . " : External Form Cache could not create Redis of Filesystem cache", 500); } //end catch } //end catch $model_core_forms_cache = new MajesticExternalFormsCacheModel($cache); return $model_core_forms_cache; })); }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); $cacheAdapterConfiguration = $config['validation_cache_adapter']; $cache = StorageFactory::factory($cacheAdapterConfiguration); return $cache; }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return null|StorageInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); self::$cache = StorageFactory::factory(isset($config['cache']) ? $config['cache'] : array()); // self::$cache->flush(); return self::$cache; }
/** * {@inheritDoc} * * @return ApiService */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); $columnisConfig = isset($config['columnis']) ? $config['columnis'] : array(); $apiConfig = isset($columnisConfig['api_settings']) ? $columnisConfig['api_settings'] : array(); if (!isset($apiConfig['client_number'])) { throw new ClientNumberNotSetException("There is no client_number set in local.php config file."); } if (!isset($apiConfig['api_base_url'])) { throw new ApiBaseUrlNotSetException("There is no api_base_url set in local.php config file."); } $clientNumber = $apiConfig['client_number']; $apiUrl = $apiConfig['api_base_url']; $httpClient = new GuzzleClient(array('base_url' => $apiUrl)); $cacheConfig = isset($config['guzzle_cache']) ? $config['guzzle_cache'] : array(); if (isset($cacheConfig['adapter'])) { $cache = StorageFactory::factory($cacheConfig); $zfCacheAdapter = new ZfCacheAdapter($cache); $cacheSubscriber = new CacheSubscriber($zfCacheAdapter, function (RequestInterface $request) use($zfCacheAdapter) { return !$zfCacheAdapter->contains($request); }); $httpClient->getEmitter()->attach($cacheSubscriber); } return new ApiService($httpClient, $clientNumber); }
public function setUp() { $this->_cacheDir = sys_get_temp_dir() . '/zend_locale_cldr'; $this->_removeRecursive($this->_cacheDir); mkdir($this->_cacheDir); $this->_cache = CacheFactory::factory(array( 'adapter' => array( 'name' => 'Filesystem', 'options' => array( 'ttl' => 1, 'cache_dir' => $this->_cacheDir, ) ), 'plugins' => array( array( 'name' => 'serializer', 'options' => array( 'serializer' => 'php_serialize', ), ), ), )); Cldr::setCache($this->_cache); }
/** * Create Service * * @param ServiceLocatorInterface $serviceLocator Zend Service Manager * * @return \Zend\Cache\Storage\StorageInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); $extraOptions = ['namespace' => 'rcmRssCache', 'ttl' => '300']; $cache = StorageFactory::factory(['adapter' => ['name' => $config['rcmCache']['adapter'], 'options' => $config['rcmCache']['options'] + $extraOptions], 'plugins' => $config['rcmCache']['plugins']]); return $cache; }
/** * {@inheritDoc} */ public function createService(ServiceLocatorInterface $serviceLocator) { /** @var $options \StrokerCache\Options\ModuleOptions */ $options = $serviceLocator->get('StrokerCache\\Options\\ModuleOptions'); $adapterOptions = array('adapter' => $options->getStorageAdapter()); return StorageFactory::factory($adapterOptions); }
/** * Enter description here... * * @return \Zend\Service\SlideShare\SlideShare */ protected function _getSSObject() { $ss = new SlideShareService(TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY, TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET, TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME, TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD, TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID); $cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); $ss->setCacheObject($cache); return $ss; }
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $this->prepareStorageFactory($container); $config = $container->get('config'); $cacheConfig = isset($config['cache']) ? $config['cache'] : []; return StorageFactory::factory($cacheConfig); }
/** * Defined by Zend\Authentication\Storage\StorageInterface * * @return void */ public function cacheClear() { $userId = $this->session->{$this->member}->userId; $cache = StorageFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => array('cache_dir' => './data/cache', 'ttl' => 3600)), 'plugins' => array('exception_handler' => array('throw_exceptions' => false), 'serializer'))); foreach ($this->remove_caches as $cache_ns) { $cache->removeItem($cache_ns . $userId); } }
public function __construct($path = '../cache') { if (!is_dir($path) && !mkdir($path, 0755, true)) { throw new \Exception('Cache path doesn\'t exist'); } $this->path = $path; $this->cache = StorageFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => array('ttl' => 3600, 'cache_dir' => $path, 'dir_level' => 1, 'dir_permission' => 0755, 'file_permission' => 0644)), 'plugins' => array('exception_handler' => array('throw_exceptions' => false), 'serializer'))); }
public function __construct($options = array()) { if (is_array($options)) { if (isset($options['cache'])) { $this->setCacheStorage(StorageFactory::factory($options['cache'])); } } }
/** * @param ServiceLocatorInterface $serviceLocator * * @return CacheStorageFactory */ public function createService(ServiceLocatorInterface $serviceLocator) { /** @var OptionsHelper $options */ $options = $serviceLocator->get('DmMailer\\Helper\\Options'); $cacheOptions = $options->getCacheStorage(); $cacheStorage = CacheStorageFactory::factory($cacheOptions); return $cacheStorage; }
/** * @return \Zend\Cache\Storage\StorageInterface */ public function getCache() { if (!$this->cache) { $cache = StorageFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => array('cache_dir' => './data/cache', 'ttl' => 3600)), 'plugins' => array('exception_handler' => array('throw_exceptions' => false), 'serializer'))); $this->cache = $cache; } return $this->cache; }
/** * Enter description here... * * @return \Zend\Service\SlideShare\SlideShare */ protected function _getSSObject() { $ss = new SlideShareService(TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY, TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET, TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME, TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD, TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID); mkdir($this->_cacheDir); $cache = CacheFactory::factory(array('adapter' => array('name' => 'Filesystem', 'options' => array('ttl' => 0, 'cache_dir' => $this->_cacheDir)), 'plugins' => array(array('name' => 'serializer', 'options' => array('serializer' => 'php_serialize'))))); $ss->setCacheObject($cache); return $ss; }
public function testMemcachedStorageNormalizesKey() { $adapter = StorageFactory::factory(array('adapter' => 'memcached', 'options' => array('ttl' => 2 * 60 * 60, 'servers' => array(array('host' => 'localhost', 'port' => 11211))))); $facade = new Facade($adapter); $key = str_repeat('http://www.foo.bar.com/Blah?=foo&baz=bat', 20); $expect = md5($key); $this->assertSame($expect, $facade->normalizeKey($key)); }
protected function setUp() { if (!class_exists('\\Zend\\Cache\\StorageFactory')) { $this->markTestSkipped('StorageFactory is not available'); } $memoryCache = StorageFactory::factory(array('adapter' => array('name' => 'memory', 'options' => array('ttl' => 100)), 'plugins' => array('exception_handler' => array('throw_exceptions' => false)))); $this->cache = new ZendCache($memoryCache); }
public function createService(ServiceLocatorInterface $serviceLocator) { // Configure the cache $config = $serviceLocator->get('Config'); $cacheConfig = isset($config['cache']) ? $config['cache'] : array(); $cache = StorageFactory::factory($cacheConfig); return $cache; }
/** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @return void */ public function setUp() { $this->clearRegistry(); $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); Currency\Currency::setCache($this->_cache); $this->helper = new Helper\Currency('de_AT'); }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); if ($config['fcache']['is_open']) { return StorageFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => $config['fcache_manager']), 'plugins' => array('exception_handler' => array('throw_exceptions' => false), 'serializer'))); } else { return false; } }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = ['adapter' => ['name' => 'apc', 'options' => ['namespace' => __NAMESPACE__, 'ttl' => 60 * 60 * 24]], 'plugins' => ['exception_handler' => ['throw_exceptions' => false], 'serializer']]; if (array_key_exists('markdown_cache', $serviceLocator->get('Config'))) { $config = $serviceLocator->get('Config')['markdown_cache']; } $cache = StorageFactory::factory($config); return $cache; }
public function preapareCache() { $cache = ZendCache::factory(array('adapter' => array('name' => 'redis', 'options' => array('ttl' => $this->getTtl())), 'plugins' => array('Serializer', 'ExceptionHandler' => array('throw_exceptions' => false), 'OptimizeByFactor' => array('optimizing_factor' => 0), 'IgnoreUserAbort' => array('exitOnAbort' => false), 'ClearExpiredByFactor' => array('clearing_factor' => 0)))); $redisOptions = new \Zend\Cache\Storage\Adapter\RedisOptions(); $redisOptions->setServer(array('host' => $this->getHost(), 'port' => $this->getPort(), 'timeout' => '30')); $redisOptions->setLibOptions(array(\Redis::OPT_SERIALIZER => \Redis::SERIALIZER_PHP)); $cache->setOptions($redisOptions); $this->setCache($cache); }