public function flush() { if (!$this->memcached) { throw new CacheException('No memcached defined.'); } $this->memcached->flush(); }
public function testSaveClear() { $x = "valB"; $this->_adapter->saveStatus('AAA', 'BBB', $x); $this->_connection->flush(); $this->assertEquals("", $this->_adapter->loadStatus('AAA', 'BBB')); }
public function setUp() { self::$memcached->flush(); self::$memcached->quit(); $this->storage = new MemcachedStorage(self::$memcached); $this->tokenBucket = new TokenBucket('test', $this->storage); }
public function setUp() { self::$memcached->flush(); self::$memcached->quit(); self::$memcached->set('found', array('count' => 5, 'time' => strtotime('2015-01-01 00:00:00'))); self::$memcached->set('oldkey', 'old story'); $this->storage = new MemcachedStorage(self::$memcached); }
function clear() { $this->memcached->flush(); // $val = $this->memcached->get($key); // if($val !== false) { // $this->memcached->delete($key); // } // TODO: Implement clear() method. }
/** * @return PeclMemcached **/ public function clean() { $this->ensureTriedToConnect(); try { $this->instance->flush(); } catch (BaseException $e) { $this->alive = false; } return parent::clean(); }
public function setUp() { parent::setUp(); $this->memcache = new \Memcached(); $this->memcache->addServer(self::TEST_MEMCACHE_SERVER, self::TEST_MEMCACHE_PORT); $this->memcache->flush(); if (!$this->memcache->set('test', 1, time() + 100)) { throw new \RuntimeException('Cannot save item to memcache. ' . $this->memcache->getResultMessage()); } }
public function flushAction() { #var_dump($this->memcached->getAllKeys()); $result = $this->memcached->flush(); #var_dump($this->memcached->getAllKeys()); #die(); if (!$result) { throw new \RuntimeException("Could not flush"); } return $this->redirectToReferrer(); }
/** * @inheritDoc */ protected function setUp() { parent::setUp(); /* Create the memcached client. */ $this->client = new \Memcached(); $this->client->addServer('127.0.0.1', 11211); /* Flush the server */ $this->client->flush(); /* Create the provider instance. */ $options = array(ProviderServiceInterface::PROVIDER_OPT_PREFIX => 'my_prefix', ProviderServiceInterface::PROVIDER_OPT_SEPARATOR => ':'); $this->provider = new MemcachedProviderService($this->client, $options); }
/** * @requires extension memcached */ protected function setUp() { if (!extension_loaded('memcached')) { $this->markTestSkipped('memcached extension not installed'); } $this->memcached = new \Memcached(); $this->memcached->addServer('127.0.0.1', 11211); $this->memcached->flush(); if (@fsockopen('127.0.0.1', 11211) === false) { unset($this->memcached); $this->markTestSkipped('Could not connect to Memcached instance'); } parent::setUp(); }
protected function setUp() { $client = new \Memcached(); $client->addServer('localhost', 11211); $client->flush(); $this->cache = new OffloadCacheMemcached($client); }
/** * Internal method to clear items off all namespaces. * * @param int $normalizedMode Matching mode (Value of Adapter::MATCH_*) * @param array $normalizedOptions * @return boolean * @throws Exception\ExceptionInterface * @see clearByNamespace() */ protected function internalClear(&$normalizedMode, array &$normalizedOptions) { if (!$this->memcached->flush()) { throw $this->getExceptionByResultCode($this->memcached->getResultCode()); } return true; }
/** * Flush all existing items in storage. * * @return boolean * * @since 3.6.3 */ public function flush() { if (!$this->lockindex()) { return false; } return static::$_db->flush(); }
/** * Flush all existing items at the server * @return bool */ public function flush() { if ($this->enabled === false) { return true; } return $this->memcached->flush(); }
/** * @return \Memcached */ protected function getMemcached() { $Memcached = new \Memcached(); $Memcached->addServers($this->getTestServers()); $Memcached->flush(); return $Memcached; }
/** * @see Cache::flush() */ public function flush() { if (!$this->is_connected) { return false; } return $this->memcached->flush(); }
/** * Flush all keys within a namespace from the cache. * * @param string $namespace The namespace to clear * * @codeCoverageIgnore */ public function flush($namespace) { // Cannot get keys here. // See comments in self::getAllKeys // $keys = $this->keys($namespace); return $this->client->flush(); }
public function clear($prefix = '') { $prefix = $this->getNamespace() . $prefix; $allKeys = self::$cache->getAllKeys(); if ($allKeys === false) { // newer Memcached doesn't like getAllKeys(), flush everything self::$cache->flush(); return true; } $keys = array(); $prefixLength = strlen($prefix); foreach ($allKeys as $key) { if (substr($key, 0, $prefixLength) === $prefix) { $keys[] = $key; } } if (method_exists(self::$cache, 'deleteMulti')) { self::$cache->deleteMulti($keys); } else { foreach ($keys as $key) { self::$cache->delete($key); } } return true; }
public static function plugin_activated() { // When the plug in is activated we flush memcache - as it might hold stale // data from a failed HTTP requests (e.g. the admin page) $memcache = new \Memcached(); $memcache->flush(); }
/** * Flush the whole storage * * @return boolean */ public function flush() { if (!$this->memcached->flush()) { throw $this->getExceptionByResultCode($this->memcached->getResultCode()); } return true; }
/** * Полная очистка кеша без скомпилированных шаблонов * @return bool true, если успешно очищено */ public function clear() { if ($this->m) { return @$this->m->flush(); } else { return @file::o()->unlink_folder('include/cache', true, array(TEMPLATES_PATH, '.gitignore')); } }
/** * (non-PHPdoc) * @see \Cachearium\Backend\CacheRAM::clear() */ public function clear() { if ($this->memcached) { $this->memcached->flush(); } parent::clear(); return true; }
protected function setUp() { $client = new \Memcached(); $client->addServer('localhost', 11211); $client->flush(); $this->base_cache = new OffloadCacheMemcached($client); $this->manager = new OffloadManager($this->base_cache, new OffloadLockMemcached($client)); }
/** * Invalidate all items in the cache. * * @link http://www.php.net/manual/en/memcached.flush.php * * @param int $delay Number of seconds to wait before invalidating the items. * @return bool Returns TRUE on success or FALSE on failure. */ public function flush($delay = 0) { $result = $this->mc->flush($delay); // Only reset the runtime cache if memcached was properly flushed if (Memcached::RES_SUCCESS === $this->getResultCode()) { $this->cache = array(); } return $result; }
/** * {@inheritdoc} * * @return \Endeveit\Cache\Interfaces\Driver */ protected static function getDriver() { if (!class_exists('Memcached')) { return null; } $memcached = new \Memcached(); $memcached->addServer('127.0.0.1', 11211); $memcached->flush(); return new Driver(array('client' => $memcached, 'prefix_id' => 'PHPUnit_')); }
/** * Flush all data from the cache server? */ public function flush() { if ($this->connected === true && $this->ping() === true) { if ($this->isRedis === true) { $this->server->flushAll(); } else { $this->server->flush(); } } }
protected function tearDown() { parent::tearDown(); if (!getenv("MEMCACHE_HOST")) { return; } $memcached = new \Memcached(); $memcached->addServer(getenv("MEMCACHE_HOST"), 11211); $memcached->flush(); }
/** * Removes items from the cache by conditions & garbage collector. * @param array conditions * @return void */ public function clean(array $conditions) { if (!empty($conditions[Cache::ALL])) { $this->memcached->flush(); } elseif ($this->journal) { foreach ($this->journal->clean($conditions) as $entry) { $this->memcached->delete($entry, 0); } } }
public static function setUpBeforeClass() { if (!extension_loaded('memcached')) { static::$cache = null; return; } $memcached = new \Memcached(); $memcached->addServer('/usr/local/var/run/memcached.sock', 0); $memcached->flush(); static::$cache = new \Cachalot\MemcachedCache($memcached, 'cachalot-test:'); }
/** * Deletes every data in the storage. * * <b>Warning!</b> Flushes the whole memcached server * * @return mixed */ public function clear() { if ($this->readOnly) { throw new StorageException('Trying to write to a read only storage'); } $debugger = Application::getInstance()->getDiContainer()->getDebugger(); $startTime = microtime(true); $this->memcache->flush(); // If we have a debugger, we have to log the request if (!$this->debuggerDisabled && $debugger !== false) { $debugger->addItem(new StorageItem('memcached', 'memcached.' . $this->currentConfigurationName, StorageItem::METHOD_CLEAR, null, microtime(true) - $startTime)); } }