/**
  * Flush cache
  *
  * @param string $namespace
  * @return boolean
  */
 protected function flush($config)
 {
     $options = $config['options'];
     unset($options['public_dir']);
     $cache = new \Zend\Cache\Storage\Adapter\Memcached($options);
     $totalSpace = $cache->getTotalSpace();
     $availableSpace = $cache->getAvailableSpace();
     $cache->flush();
     return $totalSpace - $availableSpace;
 }
Beispiel #2
0
 public function getServiceConfig()
 {
     return array('invokables' => array('serviceCurrency' => 'Course\\Service\\Currency', 'Course\\Service\\Logs' => 'Course\\Service\\Logs'), 'factories' => array('CacheAdapter' => function ($serviceManager) {
         $config = $serviceManager->get('config');
         $host = isset($config['memcached']['host']) ? $config['memcached']['host'] : 'localhost';
         $port = isset($config['memcached']['port']) ? $config['memcached']['port'] : '11211';
         $cache = new \Zend\Cache\Storage\Adapter\Memcached();
         $cache->setOptions(array('servers' => array(array($host, $port)), 'namespace' => 'MYMEMCACHEDNAMESPACE', 'liboptions' => array('COMPRESSION' => true, 'binary_protocol' => true, 'no_block' => true, 'connect_timeout' => 100)));
         $plugin = new \Zend\Cache\Storage\Plugin\ExceptionHandler();
         $plugin->getOptions()->setThrowExceptions(false);
         $cache->addPlugin($plugin);
         return $cache;
     }));
 }
Beispiel #3
0
 public function onFinish($event)
 {
     $response = $event->getApplication()->getResponse();
     $pageId = $this->getPageId();
     //Save this to memcached;
     $htmlContent = $response->getContent();
     $options = array();
     $config = $this->getConfig();
     $config = $config['cache']['page_capture'];
     $options = $config['options'];
     unset($options['public_dir']);
     $cache = new \Zend\Cache\Storage\Adapter\Memcached($options);
     $cache->setItem($pageId, $htmlContent);
 }