public function setUp() { self::$memcached->flush(); self::$memcached->quit(); $this->storage = new MemcachedStorage(self::$memcached); $this->tokenBucket = new TokenBucket('test', $this->storage); }
public function __destruct() { //Terminate active memcached connection. if (isset($this->cache)) { $this->cache->quit(); } }
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); }
public function __destruct() { if ($this->alive) { try { $this->instance->quit(); } catch (BaseException $e) { // shhhh. } } }
/** * Disconnect the open connection * * @return static */ public function disconnect() { if ($this->_connection !== null) { if (method_exists($this->_connection, 'quit')) { $this->_connection->quit(); } } $this->_connection = null; return $this; }
public function _after(TestCase $test) { $this->memcache->flush(); switch (get_class($this->memcache)) { case 'Memcache': $this->memcache->close(); break; case 'Memcached': $this->memcache->quit(); break; } }
/** * Close connection to memcache server * * @return bool */ protected function close() { if (!$this->is_connected) { return false; } return $this->memcached->quit(); }
/** * Destroy the connections. */ public function __destruct() { switch (NN_CACHE_TYPE) { case self::TYPE_REDIS: $this->server->close(); break; case self::TYPE_MEMCACHED: $this->server->quit(); break; } }
/** * Close * * Releases locks and closes connection. * * @return bool */ public function close() { if (isset($this->_memcached)) { isset($this->_lock_key) && $this->_memcached->delete($this->_lock_key); if (!$this->_memcached->quit()) { return $this->_failure; } $this->_memcached = NULL; return $this->_success; } return $this->_failure; }
/** * Close * * Releases locks and closes connection. * * @return bool */ public function close() { if (isset($this->memcached)) { isset($this->lockKey) && $this->memcached->delete($this->lockKey); if (!$this->memcached->quit()) { return false; } $this->memcached = null; return true; } return false; }
/** * Close * * Releases locks and closes connection. * * @return bool */ public function close() { if (isset($this->_memcached)) { $this->_release_lock(); if (!$this->_memcached->quit()) { return $this->_fail(); } $this->_memcached = NULL; return $this->_success; } return $this->_fail(); }
/** * Close * * Releases locks and closes connection. * * @return bool */ public function close() { if (isset($this->_memcached)) { isset($this->_lock_key) && $this->_memcached->delete($this->_lock_key); if (!$this->_memcached->quit()) { return FALSE; } $this->_memcached = NULL; return TRUE; } return FALSE; }
/** * Maybe add server connections. * * @since 151216 Memcached utilities. */ protected function maybeAddServerConnections() { if (!$this->Pool) { return; // Not possible. } if ($this->serversDiffer()) { $this->Pool->quit(); $this->Pool->resetServerList(); $this->Pool->addServers($this->servers); } }
/** * @inheritDoc */ protected function tearDown() { parent::tearDown(); /* Close all active connections. */ $this->client->quit(); }
/** * Closes connection to server(s) */ protected function _close() { return $this->_connection->quit(); }
/** * Kill one session, the session record is removed afterwards. * @param string $sid */ public function kill_session($sid) { if (!$this->servers) { return; } // Go through the list of all servers because // we do not know where the session handler put the // data. foreach ($this->servers as $server) { list($host, $port) = $server; $memcached = new \Memcached(); $memcached->addServer($host, $port); $memcached->delete($this->prefix . $sid); $memcached->quit(); } }
/** * Class destructor * Closes any open connections */ public function __destruct() { if ($this->type == self::TYPE_MEMCACHED) { $this->memcached->quit(); } }
/** * @author Damien Lasserre <*****@*****.**> * @return bool|void */ public function close() { $this->_memcached->quit(); }
/** * Kill one session, the session record is removed afterwards. * @param string $sid */ public function kill_session($sid) { if (!$this->servers) { return; } $memcached = new \Memcached(); $memcached->addServers($this->servers); $memcached->delete($this->prefix . $sid); $memcached->quit(); }
/** * Closes the memcached connection */ public function __destruct() { $this->memcached->quit(); }
public function __destruct() { parent::quit(); }
<?php $m = new Memcached(); var_dump($m->quit());
} } // Memcached // if (defined('CMW_USING_MEMCACHED') && $show_memcached) { $response['memcached_api_version'] = phpversion('memcached'); if ($is_admin) { $m = new Memcached(); $m->addServer(CMW_MEMCACHED_HOST, CMW_MEMCACHED_PORT); $m_data = $m->getStats(); //$response['memcached'] = []; // If multiple servers foreach ($m_data as $key => $value) { //$response['memcached'][$key] = $value['uptime']; // If multiple servers $response['memcached_version'] = $value['version']; $response['memcached_uptime'] = time_offset() + $value['uptime']; } $m->quit(); } } // Command Line Tools // if (defined('CMW_USING_IMAGEMAGICK') && !$show_specific && $is_admin) { unset($out); unset($ret); exec("convert -version", $out, $ret); $response['imagemagick_version'] = $ret ? "ERROR" : preg_split('/\\s+/', $out[0])[2]; } if (defined('CMW_USING_PHP_IMAGEMAGICK') && !$show_specific && $is_admin) { // TODO: this // NOTE: This is the PHP library ImageMagick, not the command line tool } if (defined('CMW_USING_PNGQUANT') && !$show_specific && $is_admin) { unset($out);
/** * Closes session * * @return bool */ public function close() { $this->_driver->quit(); }
<?php $cache = new Memcached(); $cache->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $cache->setOption(Memcached::OPT_COMPRESSION, false); $cache->addServer('localhost', 3434); $cache->add("add_key", "hello", 500); $cache->append("append_key", "world"); $cache->prepend("prepend_key", "world"); $cache->increment("incr", 2, 1, 500); $cache->decrement("decr", 2, 1, 500); $cache->delete("delete_k"); $cache->flush(1); var_dump($cache->get('get_this')); $cache->set('set_key', 'value 1', 100); $cache->replace('replace_key', 'value 2', 200); $cache->getStats(); $cache->quit(); sleep(1);
$start = microtime(true); foreach ($values as $key => $value) { $memcached->delete($key); } $del_time = sprintf('%01.4f', microtime(true) - $start); $values = array(); // Print table values printf("%-{$cellsize}s|", $itteration); printf("%-{$cellsize}s|", $set_time); printf("%-{$cellsize}s|", $get_time); printf("%-{$cellsize}s|", $miss_time); printf("%-{$cellsize}s|", $del_time); echo "\n"; // teardown Memcached connection $memcached->flush(); $memcached->quit(); $memcached = null; unset($memcached); // Store the best value for the current number of itterations // Best Set if (!isset($best_set[$itteration]['time'])) { $best_set[$itteration]['time'] = $set_time; $best_set[$itteration]['buffer'] = $buffer_key; $best_set[$itteration]['serializer'] = $serializers_key; $best_set[$itteration]['compression'] = $compression_key; $best_set[$itteration]['hash'] = $hash_key; } if ($set_time < $best_set[$itteration]['time']) { $best_set[$itteration]['time'] = $set_time; $best_set[$itteration]['buffer'] = $buffer_key; $best_set[$itteration]['serializer'] = $serializers_key;
<?php error_reporting(E_ALL); ini_set('display_errors', 'On'); function p($value = '') { echo '<pre>'; var_dump($value); echo '</pre>'; } //phpinfo(); $connect = new Memcached(); //声明一个新的memcached链接 $connect->setOption(Memcached::OPT_COMPRESSION, false); //关闭压缩功能 $connect->setOption(Memcached::OPT_BINARY_PROTOCOL, true); //使用binary二进制协议 $connect->addServer('0622aa050be911e4.m.cnqdalicm9pub001.ocs.aliyuncs.com', 11211, 100); //添加OCS实例地址及端口号 //$connect->setSaslAuthData('0622aa050be911e4', 'MYc9ju581cuXX5mP6'); //设置OCS帐号密码进行鉴权 for ($i = 0; $i < 10000; $i++) { $connect->set("hellomd5({$i})", "world{$i}"); } echo 'hello: ', $connect->get("hello"); $connect->quit();