Example #1
0
 public function testPluginWithMaster()
 {
     $c = $this->_root->getComponentByClass('Kwf_Component_Plugin_Interface_UseViewCache_Component');
     Kwf_Component_Plugin_Interface_UseViewCache_Plugin_Component::$useViewCache = true;
     $html1 = $c->render(true, true);
     Kwf_Component_Plugin_Interface_UseViewCache_Component::$num++;
     $html2 = $c->render(true, true);
     Kwf_Component_Plugin_Interface_UseViewCache_Component::$num++;
     $html3 = $c->render(true, true);
     Kwf_Component_Plugin_Interface_UseViewCache_Component::$num++;
     $this->assertEquals($html1, $html2);
     $this->assertEquals($html1, $html3);
     apc_clear_cache('user');
     Kwf_Cache::factory('Core', 'Memcached', array('lifetime' => null, 'automatic_cleaning_factor' => false, 'automatic_serialization' => true))->clean();
     Kwf_Cache_Simple::resetZendCache();
     Kwf_Component_Plugin_Interface_UseViewCache_Plugin_Component::$useViewCache = false;
     $html4 = $c->render(true, true);
     Kwf_Component_Plugin_Interface_UseViewCache_Component::$num++;
     $html5 = $c->render(true, true);
     Kwf_Component_Plugin_Interface_UseViewCache_Component::$num++;
     $html6 = $c->render(true, true);
     Kwf_Component_Plugin_Interface_UseViewCache_Component::$num++;
     $this->assertNotEquals($html3, $html4);
     $this->assertNotEquals($html4, $html5);
     $this->assertNotEquals($html4, $html6);
     $this->assertNotEquals($html5, $html6);
     Kwf_Component_Plugin_Interface_UseViewCache_Plugin_Component::$useViewCache = true;
     $html7 = $c->render(true, true);
     Kwf_Component_Plugin_Interface_UseViewCache_Component::$num++;
     $html8 = $c->render(true, true);
     Kwf_Component_Plugin_Interface_UseViewCache_Component::$num++;
     $this->assertEquals($html7, $html3);
     $this->assertEquals($html8, $html3);
 }
 public static function getValue($key, $what = self::NAME)
 {
     $language = Kwf_Trl::getInstance()->getTargetLanguage();
     $masterFile = KWF_PATH . '/Kwf/Form/Field/SelectCountry/countries.xml';
     $cacheId = "countries_{$language}_{$what}";
     $cache = Kwf_Cache::factory('File', 'File', array('master_file' => $masterFile, 'lifetime' => null, 'automatic_serialization' => true), array('cache_dir' => 'cache/config'));
     $result = $cache->load($cacheId);
     if (!$result) {
         $xml = simplexml_load_file($masterFile);
         $result = array();
         $x = 0;
         foreach ($xml->country as $country) {
             $value = null;
             foreach ($country as $k => $c) {
                 if ($k == $what) {
                     $attributes = $c->attributes();
                     if (isset($attributes['language']) && $attributes['language'] == $language) {
                         $result[(string) $country->iso2] = (string) $c;
                     }
                 }
             }
         }
         $cache->save($result, $cacheId);
     }
     if (isset($result[$key])) {
         return $result[$key];
     }
     return null;
 }
 private static function _getCache()
 {
     static $i;
     if (!$i) {
         $i = Kwf_Cache::factory('Core', 'File', array('lifetime' => null, 'automatic_serialization' => true), array('cache_dir' => 'cache/aws'));
     }
     return $i;
 }
 private function _setup($rootClass)
 {
     Kwf_Component_Data_Root::setComponentClass($rootClass);
     $this->_root = Kwf_Component_Data_Root::getInstance();
     Kwf_Component_Cache::setInstance(Kwf_Component_Cache::CACHE_BACKEND_FNF);
     Kwf_Cache::factory('Core', 'Memcached', array('lifetime' => null, 'automatic_cleaning_factor' => false, 'automatic_serialization' => true))->clean();
     Kwf_Cache_Simple::resetZendCache();
 }
Example #5
0
 public function setUp()
 {
     apc_clear_cache('user');
     Kwf_Cache::factory('Core', 'Memcached', array('lifetime' => null, 'automatic_cleaning_factor' => false, 'automatic_serialization' => true))->clean();
     Kwf_Cache_Simple::resetZendCache();
     parent::setUp();
     Kwf_Events_Dispatcher::addListeners('Kwf_Model_RowCache_RowCacheModel');
     Kwf_Model_Abstract::getInstance('Kwf_Model_RowCache_SourceModel')->setData(array(array('id' => 1, 'foo' => 1, 'bar' => 'x1'), array('id' => 2, 'foo' => 2, 'bar' => 'x2'), array('id' => 3, 'foo' => 3, 'bar' => 'x3'), array('id' => 4, 'foo' => 4, 'bar' => 'x4')));
 }
Example #6
0
 public function testMemcacheCleared()
 {
     $h = new Kwf_Util_SessionHandler();
     $h->open('', '');
     $h->write('123456789', 'asdf');
     $h->close();
     Kwf_Cache::factory('Core', 'Memcached', array('lifetime' => null, 'automatic_cleaning_factor' => false, 'automatic_serialization' => true))->clean();
     $h->open('', '');
     $this->assertEquals($h->read('123456789'), 'asdf');
     $h->close();
 }
 public function setUp()
 {
     parent::setUp();
     //clear view cache
     Kwf_Cache::factory('Core', 'Memcached', array('lifetime' => null, 'automatic_cleaning_factor' => false, 'automatic_serialization' => true))->clean();
     Kwf_Cache_Simple::resetZendCache();
     Kwf_Component_Data_Root::setComponentClass('Kwc_FavouritesSelenium_Root');
     //use custom user model
     $this->presetModel = Kwf_Registry::get('config')->user->model;
     Kwf_Registry::get('config')->user->model = 'Kwc_FavouritesSelenium_UserModel';
     //unset existing userModel instance to get new one
     $reg = Kwf_Registry::getInstance()->set('userModel', Kwf_Model_Abstract::getInstance('Kwc_FavouritesSelenium_UserModel'));
 }
 protected function _setupMetadata()
 {
     //hier drinnen damits nur gemacht wird sobald di erste Table erstellt wird
     if (!self::getDefaultMetadataCache()) {
         $frontendOptions = array('automatic_serialization' => true, 'write_control' => false);
         if (extension_loaded('apc') && PHP_SAPI != 'cli') {
             $backendOptions = array();
             $backend = 'Apc';
         } else {
             $backendOptions = array('cache_dir' => 'cache/model', 'file_name_prefix' => 'dbtable');
             $backend = 'File';
         }
         $cache = Kwf_Cache::factory('Core', $backend, $frontendOptions, $backendOptions);
         self::setDefaultMetadataCache($cache);
     }
     parent::_setupMetadata();
 }
 protected function setUp()
 {
     if (!($cfg = Kwf_Registry::get('testServerConfig'))) {
         throw new Kwf_Exception("testServerConfig not set");
     }
     Kwf_Util_Apc::callClearCacheByCli(array('type' => 'user'));
     Kwf_Cache::factory('Core', 'Memcached', array('lifetime' => null, 'automatic_cleaning_factor' => false, 'automatic_serialization' => true))->clean();
     $d = $this->_domain;
     if (!$d) {
         $domain = $cfg->server->domain;
     } else {
         if (!isset($cfg->kwc->domains->{$d})) {
             throw new Kwf_Exception("Domain '{$d}' not found in config");
         }
         $domain = $cfg->kwc->domains->{$d}->domain;
     }
     $this->setBrowserUrl('http://' . $domain . '/');
     $this->_unitTestCookie = md5(uniqid('testId', true));
     $this->captureScreenshotOnFailure = Kwf_Setup::getConfigSection() == 'vivid-test-server';
     $this->screenshotPath = '/mnt/screenshots';
     $this->screenshotUrl = 'http://screenshots.vivid';
     parent::setUp();
 }
 public static function getItemCountCache()
 {
     $frontendOptions = array('lifetime' => 3600, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => 'cache/component/');
     return Kwf_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
 }
Example #11
0
 private function _processId($id)
 {
     static $cacheIdPrefix;
     if (!isset($cacheIdPrefix)) {
         $cacheIdPrefix = Kwf_Cache::getUniquePrefix();
     }
     return $cacheIdPrefix . $this->_options['cache_id_prefix'] . $id;
 }
Example #12
0
 public static function stats()
 {
     header('Content-Type: text/plain; charset=utf-8');
     $mem = apc_sma_info(true);
     $memSize = $mem['num_seg'] * $mem['seg_size'];
     $memAvailable = $mem['avail_mem'];
     echo "size: " . round($memSize / (1024 * 1024)) . " MB\n";
     echo "avail: " . round($memAvailable / (1024 * 1024)) . " MB\n\n";
     $prefix = Kwf_Cache::getUniquePrefix();
     $it = new APCIterator('user', '#^' . preg_quote($prefix) . '#', APC_ITER_KEY);
     echo $it->getTotalCount() . " entries\n";
     echo round($it->getTotalSize() / (1024 * 1024)) . " MB size\n\n";
     $totalSize = $it->getTotalSize();
     $it = new APCIterator('user', '#^' . preg_quote($prefix . '-cc-') . '#', APC_ITER_KEY);
     echo "view cache:\n";
     echo $it->getTotalCount() . " entries\n";
     echo round($it->getTotalSize() / (1024 * 1024)) . " MB (" . round($it->getTotalSize() / $totalSize * 100) . "%)\n\n";
     $it = new APCIterator('user', '#^' . preg_quote($prefix . '-procI-') . '#', APC_ITER_KEY);
     echo "processInput cache:\n";
     echo $it->getTotalCount() . " entries\n";
     echo round($it->getTotalSize() / (1024 * 1024)) . " MB (" . round($it->getTotalSize() / $totalSize * 100) . "%)\n\n";
     $it = new APCIterator('user', '#^' . preg_quote($prefix . '-url-') . '#', APC_ITER_KEY);
     echo "url cache:\n";
     echo $it->getTotalCount() . " entries\n";
     echo round($it->getTotalSize() / (1024 * 1024)) . " MB (" . round($it->getTotalSize() / $totalSize * 100) . "%)\n\n";
     $it = new APCIterator('user', '#^' . preg_quote($prefix . '-config-') . '#', APC_ITER_KEY);
     echo "config cache:\n";
     echo $it->getTotalCount() . " entries\n";
     echo round($it->getTotalSize() / (1024 * 1024)) . " MB (" . round($it->getTotalSize() / $totalSize * 100) . "%)\n\n";
     $load = explode(' ', file_get_contents('/proc/loadavg'));
     echo "load: " . $load[0] . "\n";
     exit;
 }
Example #13
0
 private function _getCache()
 {
     return Kwf_Cache::factory('Core', 'File', array('lifetime' => 3600, 'automatic_serialization' => true), array('cache_dir' => 'cache/model', 'file_name_prefix' => 'progressbar'));
 }
 protected function _clearCache($options)
 {
     $cache = Kwf_Cache::factory('Core', 'Memcached', array('lifetime' => null, 'automatic_cleaning_factor' => false, 'automatic_serialization' => true));
     $cache->clean();
 }
 private function _getCache()
 {
     return Kwf_Cache::factory('Core', 'File', array('lifetime' => 280, 'automatic_serialization' => true), array('cache_dir' => 'cache/config', 'file_name_prefix' => 'login_brute_force_'));
 }
 private function _getCache()
 {
     if (!$this->_cache) {
         $frontendOptions = array('lifetime' => 3600, 'automatic_serialization' => true);
         $backendOptions = array('cache_dir' => 'cache/model', 'file_name_prefix' => 'proxycache');
         $this->_cache = Kwf_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     }
     return $this->_cache;
 }
 public function graphAction()
 {
     $frontendOptions = array('lifetime' => 60 * 5, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => 'cache/benchmark/');
     $cache = Kwf_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     $cacheId = md5('graph_' . $this->_getParam('rrd') . '_' . $this->_getParam('name') . '_' . $this->_getParam('start'));
     if (!($output = $cache->load($cacheId))) {
         $rrd = $this->_rrds[$this->_getParam('rrd')];
         $graphs = $rrd->getGraphs();
         $g = $graphs[$this->_getParam('name')];
         $output = array();
         $start = strtotime($this->_getParam('start'));
         if (!$start) {
             throw new Kwf_ClientException("invalid start");
         }
         $output['contents'] = $g->getContents($start);
         $output['mimeType'] = 'image/png';
         $cache->save($output, $cacheId);
     }
     Kwf_Media_Output::output($output);
 }
Example #18
0
 private static function _getMetadataCache()
 {
     static $ret;
     if (!isset($ret)) {
         $frontendOptions = array('automatic_serialization' => true, 'write_control' => false);
         if (extension_loaded('apc') && PHP_SAPI != 'cli') {
             $backendOptions = array();
             $backend = 'Apc';
         } else {
             $backendOptions = array('cache_dir' => 'cache/model', 'file_name_prefix' => 'servicemeta');
             $backend = 'File';
         }
         $ret = Kwf_Cache::factory('Core', $backend, $frontendOptions, $backendOptions);
     }
     return $ret;
 }