Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 public function __destruct()
 {
     if ($this->alive) {
         try {
             $this->instance->quit();
         } catch (BaseException $e) {
             // shhhh.
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 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;
     }
 }
Ejemplo n.º 7
0
 /**
  * Close connection to memcache server
  *
  * @return bool
  */
 protected function close()
 {
     if (!$this->is_connected) {
         return false;
     }
     return $this->memcached->quit();
 }
Ejemplo n.º 8
0
 /**
  * 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;
 }
Ejemplo n.º 10
0
 /**
  * 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;
 }
Ejemplo n.º 11
0
 /**
  * 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();
 }
Ejemplo n.º 12
0
 /**
  * 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;
 }
Ejemplo n.º 13
0
 /**
  * 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();
 }
Ejemplo n.º 15
0
 /**
  * Closes connection to server(s)
  */
 protected function _close()
 {
     return $this->_connection->quit();
 }
Ejemplo n.º 16
0
 /**
  * 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();
     }
 }
Ejemplo n.º 17
0
 /**
  * Class destructor
  * Closes any open connections
  */
 public function __destruct()
 {
     if ($this->type == self::TYPE_MEMCACHED) {
         $this->memcached->quit();
     }
 }
Ejemplo n.º 18
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  * @return bool|void
  */
 public function close()
 {
     $this->_memcached->quit();
 }
Ejemplo n.º 19
0
 /**
  * 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();
 }
Ejemplo n.º 20
0
 /**
  * Closes the memcached connection
  */
 public function __destruct()
 {
     $this->memcached->quit();
 }
Ejemplo n.º 21
0
 public function __destruct()
 {
     parent::quit();
 }
Ejemplo n.º 22
0
<?php

$m = new Memcached();
var_dump($m->quit());
Ejemplo n.º 23
0
    }
}
// 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);
Ejemplo n.º 24
0
 /**
  * Closes session
  *
  * @return bool
  */
 public function close()
 {
     $this->_driver->quit();
 }
Ejemplo n.º 25
0
<?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);
Ejemplo n.º 26
0
 $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;
Ejemplo n.º 27
0
<?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();