function srvc_redis_dump_info() { // https://github.com/phpredis/phpredis#close $redis = new Redis(); $redis->connect('127.0.0.1'); $redis_info = $redis->info(); $redis->close(); $json = json_encode($redis_info); echo "{$json}"; }
/** * Отключение от Redis. * * @return void * @access public * @static */ public static function close() { if (static::$redis) { static::$redis->close(); static::$redis = null; } }
public function tearDown() { if ($this->redis) { $this->redis->close(); } // unset($this->redis); }
public function __destruct() { if ($this->instance) { $this->instance->close(); unset($this->instance); } }
public static function tearDownAfterClass() { parent::tearDownAfterClass(); self::clear(self::$conn); self::$conn->close(); self::$conn = null; }
/** * connect to redis server * * @param string $host * @param integer $port * @param integer $timeout * @throws Tinebase_Exception_Backend */ public function connect($host = null, $port = null, $timeout = null) { if ($this->_redis instanceof Redis) { $this->_redis->close(); } $host = $host ? $host : $this->_options['host']; $port = $port ? $port : $this->_options['port']; $timeout = $timeout ? $timeout : $this->_options['timeout']; $this->_redis = new Redis(); if (!$this->_redis->connect($host, $port, $timeout)) { throw new Tinebase_Exception_Backend('Could not connect to redis server at ' . $host); } }
function initModules($application) { $redis = new Redis(); $redis->connect(CACHE_HOSTNAME, CACHE_PORT); $redis->select(CACHE_DB); $modulesKey = $application . '-modules'; $modules = $redis->get($modulesKey); if (empty($modules)) { $modules = []; $dir = __DIR__ . '/../../' . $application . '/modules'; $dirpath = realpath($dir); $filenames = scandir($dir); foreach ($filenames as $filename) { if ($filename == '.' || $filename == '..') { continue; } if (is_file($dirpath . DIRECTORY_SEPARATOR . $filename . '/Module.php')) { $modules[strtolower($filename)] = ['class' => $application . '\\modules\\' . $filename . '\\Module']; } } $redis->set($modulesKey, serialize([$modules, null])); } else { $modules = unserialize($modules); if (!empty($modules[0])) { $modules = $modules[0]; } } $redis->close(); return $modules; }
/** * {@inheritDoc} * @see \Mcustiel\SimpleCache\Interfaces\CacheInterface::finish() */ public function finish() { if ($this->connection !== null) { $this->connection->close(); $this->connection = null; } }
public function __destruct() { try { if ($this->_redis) { $this->_redis->close(); } } catch (Exception $e) {} }
/** * */ public function close() { if ($this->_socket) { $this->_socket->close(); $this->_socket = null; } }
public function process() { $this->params['output'] = 'json'; $context = \CADB\Model\Context::instance(); if (!($rdb = $context->getProperty('service.redis'))) { $this->result = array('found' => false, 'error' => "자동완성 기능이 활성화되어 있지 않습니다."); } else { if (!$this->params['q']) { $this->result = array('found' => false, 'error' => "자동완성할 키워드를 입력하세요."); } else { $redis = new \Redis(); try { $redis->connect('127.0.0.1', '6379', 2.5, NULL, 150); if ($redis->select($rdb) == false) { $this->result = array('found' => false, 'error' => "index 1 database 에 연결할 수 없습니다."); } else { $this->recommand = $redis->zRange($this->params['q'], 0, -1); if (@count($this->recommand)) { $this->result = array('found' => true, 'total_cnt' => @count($this->recommand)); } else { $this->result = array('found' => true, 'total_cnt' => 0); } } } catch (RedisException $e) { var_dump($e); } $redis->close(); } } }
/** * Class destructor * * Closes the connection to Redis if present. * * @return void */ public function __destruct() { // if ($this->_redis && $this->is_supported()) if ($this->_redis) { $this->_redis->close(); } }
/** * Closes a connection. * * @return bool Always true */ public function close() { if ($this->isConnected()) { $this->_connection->close(); } $this->connected = false; $this->_connection = null; return true; }
public function close() { if ($this->_connected) { try { $this->_redis->close(); } catch (Exception $e) { } $this->_connected = false; } }
public function __construct() { $redis = new Redis(); try { $redis->connect('127.0.0.1', 6379); $this->data = array('count' => $redis->get('cobbler:count'), 'speed' => $redis->get('cobbler:speed')); $redis->close(); } catch (Exception $e) { $this->error(500, $e->getMessage()); } }
/** * 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; } }
/** * Properly close the connection. */ public function __destruct() { if ($this->redis instanceof Redis) { try { $this->redis->close(); } catch (RedisException $e) { /* * \Redis::close will throw a \RedisException("Redis server went away") exception if * we haven't previously been able to connect to Redis or the connection has severed. */ } } }
/** * @return void */ public function __destruct() { // clean all messages sent and not parsed to skip unexpected errors // on next run... // Note: all keys have full name, trim keys until getting them without prefix $prefixOffset = strlen($this->prefix); $keys = array_map(function ($key) use($prefixOffset) { return substr($key, $prefixOffset); }, array_filter($this->client->keys("*"), function ($key) { return preg_match(sprintf("/^(%s)/", preg_quote($this->prefix, "/")), $key); })); $this->client->delete($keys); $this->client->close(); }
/** * Queue a task to be run by Celery. * * @param task Celery task name. * @param args (Optional) array of arguments. * @param kwargs (Optional) hash of keyword arguments. */ function queue_task($task, $args = null, $kwargs = null) { // assemble Celery-ready messages $body = array("id" => uniqid(CELERY_ID_PREFIX), "task" => $task); if (!empty($args)) { $body["args"] = $args; } if (!empty($kwargs)) { $body["kwargs"] = $kwargs; } $envelope = array("content-encoding" => "utf-8", "content-type" => "application/json", "body" => base64_encode(json_encode($body)), "properties" => array("body_encoding" => "base64", "delivery_tag" => uniqid(CELERY_ID_PREFIX), "delivery_mode" => 2, "delivery_info" => array("exchange" => CELERY_REDIS_KEY, "routing_key" => CELERY_REDIS_KEY, "priority" => 0))); $redis = new Redis(); $redis->connect(REDIS_HOST); $redis->lPush(CELERY_REDIS_KEY, json_encode($envelope)); $redis->close(); }
function redis_user_logged($uid) { if (!class_exists('Redis') || !REDIS_MODE) { return FALSE; } $redis = new Redis(); $is_success = $redis->pconnect(REDIS_SERVER_HOST, REDIS_SERVER_PORT); if (!$is_success) { $redis->connect(REDIS_SERVER_HOST, REDIS_SERVER_PORT); } $is_logged = $redis->get('uid_' . $uid . '_login'); $redis->close(); if (intval($is_logged) == 1) { return TRUE; } return FALSE; }
/** * Destructor */ public function __destruct() { if (null !== $this->redis) { $this->redis->close(); } }
/** * Class destructor * * Closes the connection to Redis if present. * * @return void */ public function __destruct() { if ($this->_redis) { $this->_redis->close(); } }
/** * 关闭Redis * * @return void */ public function close() { return $this->redis->close(); }
/** * @return bool */ public function close() { $result = TRUE; if ($this->connected && !$this->persistent) { try { $result = $this->standalone ? fclose($this->redis) : $this->redis->close(); $this->connected = FALSE; } catch (Exception $e) { // Ignore exceptions on close } } return $result; }
/** * @return bool */ public function close() { return parent::close(); }
/** * @return bool */ public function close() { $result = TRUE; if ($this->connected) { if ($this->standalone) { $result = fclose($this->redis); } else { $result = $this->redis->close(); } $this->connected = FALSE; } return $result; }
public function op_redis($IP_Port, $key, $type) { $redis = new Redis(); $redis->connect($IP_Port); if ($type == "str") { $res = $redis->get($key); } $redis->close(); return "{\"" . $key . "\":\"" . $res . "\"}"; }
<?php $redis = new Redis(); $r = $redis->connect('10.240.0.2', 6379, 1); if ($r) { $key = $redis->incr('key'); $redis->close(); var_dump($key); } else { header("HTTP/1.0 502 sys busy"); }
/** * Disconnects from the redis server */ public function __destruct() { if (!$this->settings['persistent']) { $this->_Redis->close(); } }
public function __destruct() { // TODO: Implement __destruct() method. if (isset($this->redis) && $this->redis instanceof Redis) { $this->redis->close(); } }