예제 #1
0
파일: Oredis.php 프로젝트: superbogy/cargo
 public function __construct($config)
 {
     $redis = new \redis();
     if (isset($config['PCONNECT'])) {
         $redis->pconnect($config['HOST'], $config['PORT'], $config['TIMEOUT']);
     } else {
         $redis->connect($config['HOST'], $config['PORT'], $config['TIMEOUT']);
     }
     $redis->setOption(\redis::OPT_SERIALIZER, \redis::SERIALIZER_NONE);
     $redis->select($config['DB']);
     $this->redis = $redis;
     self::$config = $config;
 }
예제 #2
0
/* 这里替换为实例id和实例password,没有则注释掉 */
/*$user = "******";
$pwd = "xxxxxxx";*/
$Redis = new redis();
//$Redis->pconnect('127.0.0.1', 6379);
if ($Redis->pconnect($host, $port) == false) {
    die($Redis->getLastError());
}
//如果没有账户密码,就注释掉
/*if ($Redis->auth($user . ":" . $pwd) == false) {
    die($Redis->getLastError());
}*/
file_put_contents('./redis.json', '');
$it = NULL;
/* Initialize our iterator to NULL */
$Redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);
/* retry when we get no keys back */
while ($keys = $Redis->scan($it)) {
    $out = '';
    foreach ($keys as $key) {
        //echo $Redis->type($key),"\n";
        $arr = array();
        $type = $Redis->type($key);
        $expire = $Redis->ttl($key);
        switch ($type) {
            case $Redis::REDIS_STRING:
                //echo "string\n";
                $arr['expire'] = $expire;
                $arr['type'] = $type;
                $arr['key'] = $key;
                $arr['val'] = $Redis->get($key);
예제 #3
0
파일: ssdb.php 프로젝트: tianyunchong/php
<?php

/**
 * 查询下关键词信息的ssdb的存储
 */
$type = "pd";
$keyword = "冰岛鲨鱼肝油软胶囊";
$key = 'wd:' . $type . ':' . $keyword;
$redis = new redis();
$redis->pconnect('172.17.16.47', 6380, 1);
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
$rs = $redis->get($key);
var_dump($rs);