예제 #1
0
 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'));
 }
예제 #3
0
 public function setUp()
 {
     self::$memcached->flush();
     self::$memcached->quit();
     $this->storage = new MemcachedStorage(self::$memcached);
     $this->tokenBucket = new TokenBucket('test', $this->storage);
 }
예제 #4
0
 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);
 }
예제 #5
0
 function clear()
 {
     $this->memcached->flush();
     //        $val = $this->memcached->get($key);
     //        if($val !== false) {
     //            $this->memcached->delete($key);
     //        }
     // TODO: Implement clear() method.
 }
예제 #6
0
 /**
  * @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());
     }
 }
예제 #8
0
 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);
 }
예제 #10
0
 /**
  * @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();
 }
예제 #11
0
 protected function setUp()
 {
     $client = new \Memcached();
     $client->addServer('localhost', 11211);
     $client->flush();
     $this->cache = new OffloadCacheMemcached($client);
 }
예제 #12
0
 /**
  * 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;
 }
예제 #13
0
 /**
  * Flush all existing items in storage.
  *
  * @return  boolean
  *
  * @since   3.6.3
  */
 public function flush()
 {
     if (!$this->lockindex()) {
         return false;
     }
     return static::$_db->flush();
 }
예제 #14
0
 /**
  * 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;
 }
예제 #16
0
 /**
  * @see Cache::flush()
  */
 public function flush()
 {
     if (!$this->is_connected) {
         return false;
     }
     return $this->memcached->flush();
 }
예제 #17
0
 /**
  * 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();
 }
예제 #18
0
 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;
 }
예제 #19
0
 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();
 }
예제 #20
0
 /**
  * Flush the whole storage
  *
  * @return boolean
  */
 public function flush()
 {
     if (!$this->memcached->flush()) {
         throw $this->getExceptionByResultCode($this->memcached->getResultCode());
     }
     return true;
 }
예제 #21
0
 /**
  * Полная очистка кеша без скомпилированных шаблонов
  * @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'));
     }
 }
예제 #22
0
 /**
  * (non-PHPdoc)
  * @see \Cachearium\Backend\CacheRAM::clear()
  */
 public function clear()
 {
     if ($this->memcached) {
         $this->memcached->flush();
     }
     parent::clear();
     return true;
 }
예제 #23
0
 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;
 }
예제 #25
0
 /**
  * {@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_'));
 }
예제 #26
0
파일: Cache.php 프로젝트: sebst3r/nZEDb
 /**
  * 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);
         }
     }
 }
예제 #29
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:');
 }
예제 #30
0
 /**
  * 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));
     }
 }