/** * {@inheritdoc} */ public function flushAll() { if ($this->currentOnly) { return apc_clear_cache('user') && apc_clear_cache(); } $result = true; foreach ($this->servers as $server) { if (count(explode('.', $server['ip'])) == 3) { $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); } else { $socket = socket_create(AF_INET6, SOCK_STREAM, SOL_TCP); } // generate the raw http request $command = sprintf("GET %s HTTP/1.1\r\n", $this->getUrl()); $command .= sprintf("Host: %s\r\n", $server['domain']); if ($server['basic']) { $command .= sprintf("Authorization: Basic %s\r\n", $server['basic']); } $command .= "Connection: Close\r\n\r\n"; // setup the default timeout (avoid max execution time) socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 2, 'usec' => 0)); socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 2, 'usec' => 0)); socket_connect($socket, $server['ip'], $server['port']); socket_write($socket, $command); $content = ''; do { $buffer = socket_read($socket, 1024); $content .= $buffer; } while (!empty($buffer)); if ($result) { $result = substr($content, -2) == 'ok'; } } return $result; }
public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { switch ($mode) { case Zend_Cache::CLEANING_MODE_ALL: $ret = true; if (php_sapi_name() == 'cli') { $ret = Kwf_Util_Apc::callClearCacheByCli(array('type' => 'user')); } if (extension_loaded('apcu')) { return $ret && apc_clear_cache('user'); } else { return $ret && apc_clear_cache(); } break; case Zend_Cache::CLEANING_MODE_OLD: $this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend"); break; case Zend_Cache::CLEANING_MODE_MATCHING_TAG: case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_APC_BACKEND); break; default: Zend_Cache::throwException('Invalid mode for clean() method'); break; } }
public function postflight($type, $parent) { $this->fixUpdateSite(); // Clear Joomla system cache. /** @var JCache|JCacheController $cache */ $cache = JFactory::getCache(); $cache->clean('_system'); // Remove all compiled files from APC cache. if (function_exists('apc_clear_cache')) { @apc_clear_cache(); } if ($type == 'uninstall') { return true; } $this->enablePlugin('system', 'kunena'); $this->enablePlugin('quickicon', 'kunena'); $app = JFactory::getApplication(); if (version_compare(JVERSION, '3.0', '>')) { $modal = <<<EOS <div id="kunena-modal" class="modal hide fade"><div class="modal-body"></div></div><script>jQuery('#kunena-modal').remove().prependTo('body').modal({backdrop: 'static', keyboard: false, remote: '{$this->makeRoute('index.php?option=com_kunena&view=install&format=raw')}'})</script> EOS; } else { $modal = "<script>window.addEvent('domready',function(){SqueezeBox.open('{$this->makeRoute('index.php?option=com_kunena&view=install&tmpl=component')}',{size:{x:530,y:140},sizeLoading:{x:530,y:140},closable:false,handler:'iframe'});});</script>"; } $app->enqueueMessage('Installing Kunena... ' . $modal); return true; }
/** * Clean up all. */ public function tearDown() { if ($this->testSkipped) { return; } apc_clear_cache('user'); }
/** * Deletes all items in the pool. * * @return boolean * True if the pool was successfully cleared. False if there was an error. */ public function clear() { if (function_exists('apcu_clear_cache')) { return apcu_clear_cache(); } return apc_clear_cache("user"); }
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); }
/** * clear static cache with prefix, don't use except in clear-cache-watcher * * @internal */ public static function clear($cacheIdPrefix) { if (extension_loaded('apc')) { if (PHP_SAPI == 'cli') { Kwf_Util_Apc::callClearCacheByCli(array('clearCacheSimpleStatic' => $cacheIdPrefix)); } else { if (!class_exists('APCIterator')) { throw new Kwf_Exception_NotYetImplemented("We don't want to clear the whole"); } else { static $prefix; if (!isset($prefix)) { $prefix = Kwf_Cache_Simple::getUniquePrefix() . '-'; } $it = new APCIterator('user', '#^' . preg_quote($prefix . $cacheIdPrefix) . '#', APC_ITER_NONE); if ($it->getTotalCount() && !$it->current()) { //APCIterator is borked, delete everything //see https://bugs.php.net/bug.php?id=59938 if (extension_loaded('apcu')) { apc_clear_cache(); } else { apc_clear_cache('user'); } } else { //APCIterator seems to work, use it for deletion apc_delete($it); } } } } else { //don't use $cacheIdPrefix as filenames are base64 encoded foreach (glob('cache/simple/*') as $f) { unlink($f); } } }
public function clear() { if (!$this->isConnected()) { return false; } return apc_clear_cache('user'); }
public function testSaveClear() { $x = "valB"; $this->_adapter->saveStatus('AAA', 'BBB', $x); apc_clear_cache('user'); $this->assertEquals("", $this->_adapter->loadStatus('AAA', 'BBB')); }
/** * Try to reset any opcode caches we know about * * @todo make it so developers can extend this somehow */ public static function cleanOpcodes() { // APC if (function_exists('apc_clear_cache') && ini_get('apc.stat') == 0) { apc_clear_cache(); } // Wincache if (function_exists('wincache_refresh_if_changed')) { wincache_refresh_if_changed(); } // Zend if (function_exists('accelerator_reset')) { accelerator_reset(); } // eAccelerator if (function_exists('eaccelerator_clear')) { eaccelerator_clear(); } // XCache if (function_exists('xcache_clear_cache') && !ini_get('xcache.admin.enable_auth')) { $max = xcache_count(XC_TYPE_PHP); for ($i = 0; $i < $max; $i++) { if (!xcache_clear_cache(XC_TYPE_PHP, $i)) { break; } } } }
function _remove_all() { if (!self::$apc_operational) { return; } apc_clear_cache('user'); }
/** * */ function onAction() { global $application; $request = $application->getInstance('Request'); $instance = $request->getValueByKey('instance'); $log_clear_type = $request->getValueByKey('log_clear_type'); $value = ''; switch ($instance) { case 'cache': CCacheFactory::clearAll(); $value = getMsg("SYS", "MSG_CACHE_CLEARED"); if (APC_EXTENSION_LOADED) { apc_clear_cache("user"); } break; case 'timeline': modApiFunc('Timeline', 'clearTimeline', $log_clear_type); $timeline = modApiFunc('Timeline', 'getTimelineRecsCount'); if ($timeline == 0) { $value = getMsg("SYS", "ADMIN_PHP_FILES_NO_LOG_RECORDS"); } else { $value = $timeline . getMsg("SYS", "ADMIN_PHP_FILES_LOG_RECORDS"); } break; default: break; } return $value; }
/** * Clear the entire cache. */ public static function clear() { if (Cache::$skip) { return; } apc_clear_cache('user'); }
public function tearDown() { unset($this->cassandra); if (function_exists('apc_clear_cache')) { apc_clear_cache(); } }
public function clear() { if ($this->apcu) { return apcu_clear_cache(); } return apc_clear_cache(); }
public static function clearDatabase() { apc_clear_cache(); $database = new DatabaseManager(); //$resource = $database->query("SELECT DATABASE()"); //$name = $resource->fetch_row()[0]; //$resource->close(); //make sure we don't accidentally load dummy data on live database //to do: make sure this actually works //if(strpos($name, "test" === false)) { if (!$database->debug()) { throw new Exception("Database may not be safe to run tests on"); } //addon_addons, addon_boards, addon_tags, addon_tagmap, group_groups, group_usermap, addon_comments, addon_ratings if (!$database->query("SET FOREIGN_KEY_CHECKS=0")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("DROP TABLE IF EXISTS addon_tagmap, addon_tags, addon_dependency,\n\t\t\taddon_addons, addon_boards, addon_comments, addon_ratings, addon_stats,\n\t\t\tusers, build_builds, build_dependency, build_stats, tag_stats, group_groups, group_usermap,\n\t\t\tstatistics, screenshots, build_screenshotmap, addon_screenshotmap")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("SET FOREIGN_KEY_CHECKS=1")) { throw new Exception("Database error: " . $database->error()); } apc_clear_cache(); }
public function testApcAsResultCache() { if (!extension_loaded("apc")) { return; } // clear user cache to make sure we always get the same behavior: // 1st iteration cache miss, subsequent iterations cache hit. apc_clear_cache("user"); $cacheDriver = new Doctrine_Cache_Apc(); $this->conn->setAttribute(Doctrine::ATTR_RESULT_CACHE, $cacheDriver); $queryCountBefore = $this->conn->count(); for ($i = 0; $i < 10; $i++) { $u = Doctrine_Query::create() ->from('User u') ->addWhere('u.name = ?', array('Hans')) ->useResultCache() ->execute(); $this->assertEqual(1, count($u)); $this->assertEqual("Hans", $u[0]->name); } // Just 1 query should be run $this->assertEqual($queryCountBefore + 1, $this->conn->count()); }
/** * Clear datas with $uid key * @param mixed $uid * @return void */ public function clear($uid = null) { if ($uid) { return apc_delete($uid); } return apc_clear_cache(); }
/** * Clears the APC cache to push out old entries */ public function clearAPCCache() { if (function_exists("apc_clear_cache")) { apc_clear_cache(); apc_clear_cache("user"); } }
/** * function to clear all cache data * by default accessible only for admin * * @access Public * @return void */ public function clear_cache() { $this->autoRender = false; Cache::clear(); clearCache(); $files = array(); $files = array_merge($files, glob(CACHE . '*')); // remove cached css $files = array_merge($files, glob(CACHE . 'css' . DS . '*')); // remove cached css $files = array_merge($files, glob(CACHE . 'js' . DS . '*')); // remove cached js $files = array_merge($files, glob(CACHE . 'models' . DS . '*')); // remove cached models $files = array_merge($files, glob(CACHE . 'persistent' . DS . '*')); // remove cached persistent foreach ($files as $f) { if (is_file($f)) { unlink($f); } } if (function_exists('apc_clear_cache')) { apc_clear_cache(); apc_clear_cache('user'); } $this->set(compact('files')); $this->layout = 'ajax'; }
protected function tearDown() { // remove test file unlink($this->getConfigFile()); // clear the cache $this->assertTrue(apc_clear_cache("user")); }
/** * Apc缓存-清空所有缓存 * 不建议使用该功能 * @return */ public function clear_all() { apc_clear_cache('user'); //清除用户缓存 return apc_clear_cache(); //清楚缓存 }
/** */ function flush() { if (!$this->is_ready()) { return null; } return apc_clear_cache() && apc_clear_cache('user'); }
/** * @param int $iTimeToClearInHours = 24 * * @return bool */ public function gc($iTimeToClearInHours = 24) { if (0 === $iTimeToClearInHours) { return \apc_clear_cache('user'); } return false; }
public function testGetActionsNotSet() { apc_clear_cache(); $cache = new ExtCache($this->cacheKey); $this->assertFalse($cache->isCached()); $this->assertEmpty($cache->getActions()); }
public function tearDown() { parent::tearDown(); if (extension_loaded('apc')) { apc_clear_cache('user'); } }
function cs_cache_clear() { apc_clear_cache('user'); $unicode = extension_loaded('unicode') ? 1 : 0; $where = "options_mod = 'clansphere' AND options_name = 'cache_unicode'"; cs_sql_update(__FILE__, 'options', array('options_value'), array($unicode), 0, $where); }
public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { switch ($mode) { case Zend_Cache::CLEANING_MODE_ALL: $ret = true; if (PHP_SAPI == 'cli') { if (Kwf_Config::getValue('externalClearCacheScript')) { throw new Kwf_Exception("Dont't delete complete apc-user cache via cli."); } $ret = Kwf_Util_Apc::callClearCacheByCli(array('type' => 'user')); } if (extension_loaded('apcu')) { return $ret && apc_clear_cache('user'); } else { return $ret && apc_clear_cache(); } break; case Zend_Cache::CLEANING_MODE_OLD: $this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend"); break; case Zend_Cache::CLEANING_MODE_MATCHING_TAG: case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_APC_BACKEND); break; default: Zend_Cache::throwException('Invalid mode for clean() method'); break; } }
public function getBackend() { apc_clear_cache('user'); $this->backendPrefix = 'prefix/'; $backend = new \Cachet\Backend\APC('prefix'); return $backend; }
/** * @requires extension redis */ protected function setUp() { if (!extension_loaded('apcu')) { $this->markTestSkipped('apcu extension not installed'); } apc_clear_cache('user'); parent::setUp(); }