当前位置: 首页>>代码示例>>PHP>>正文


PHP Redis::getMultiple方法代码示例

本文整理汇总了PHP中Redis::getMultiple方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::getMultiple方法的具体用法?PHP Redis::getMultiple怎么用?PHP Redis::getMultiple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redis的用法示例。


在下文中一共展示了Redis::getMultiple方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getMulti

 /**
  * {@inheritDoc}
  *
  * @link https://github.com/phpredis/phpredis#mget-getmultiple
  */
 protected function _getMulti(array $keys)
 {
     $values = $this->_connection->getMultiple($keys);
     if (empty($values)) {
         return array_fill_keys($keys, false);
     }
     // Note: returns an array of *only* values, keys need to be merged
     return array_combine($keys, $values);
 }
开发者ID:behance,项目名称:nbd.php-cache,代码行数:14,代码来源:RedisAdapter.php

示例2: getMulti

 /**
  * @param $keys
  * @return array|bool
  */
 public function getMulti($keys)
 {
     try {
         $this->_useCnt++;
         return parent::getMultiple($keys);
     } catch (Exception $e) {
         Wk::logger()->err($e->getMessage());
     }
     return false;
 }
开发者ID:telander,项目名称:waka,代码行数:14,代码来源:Wk_Redis.php

示例3: testMultipleBin

 public function testMultipleBin()
 {
     $this->redis->delete('k1');
     $this->redis->delete('k2');
     $this->redis->delete('k3');
     $this->redis->set('k1', gzcompress('v1'));
     $this->redis->set('k2', gzcompress('v2'));
     $this->redis->set('k3', gzcompress('v3'));
     $this->assertEquals(array(gzcompress('v1'), gzcompress('v2'), gzcompress('v3')), $this->redis->getMultiple(array('k1', 'k2', 'k3')));
     $this->assertEquals(array(gzcompress('v1'), gzcompress('v2'), gzcompress('v3')), $this->redis->getMultiple(array('k1', 'k2', 'k3')));
 }
开发者ID:virtulis,项目名称:phpredis,代码行数:11,代码来源:TestRedis.php

示例4: explode

<?php

/**
 * 查询单个企业信息
 */
header("Content-type:text/html;charset=utf-8");
define("App", "product");
if (isset($_GET["cid"])) {
    $cid = explode(",", $_GET["cid"]);
    $cid = array_filter($cid);
} else {
    exit("请传入cid参数!");
}
if (App == "dev") {
    $config = array('192.168.8.189', 8888);
} else {
    $config = array('172.17.16.47', 8888);
}
$redis = new Redis();
$redis->pconnect($config[0], $config[1], 1);
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
$keys = array();
foreach ($cid as $value) {
    $keys[] = "gc:cominfo:" . $value;
}
$rs = $redis->getMultiple($keys);
foreach ($rs as $v) {
    var_dump($v);
    echo "\n";
}
开发者ID:tianyunchong,项目名称:php,代码行数:30,代码来源:detail.php

示例5: checkSerializer


//.........这里部分代码省略.........
     // zDelete
     $this->assertTrue(1 === $this->redis->zDelete('key', $z[3]));
     $this->assertTrue(0 === $this->redis->zDelete('key', $z[3]));
     unset($z[3]);
     // check that zDelete doesn't crash with a missing parameter (GitHub issue #102):
     $this->assertTrue(FALSE === @$this->redis->zDelete('key'));
     // variadic
     $this->redis->delete('k');
     $this->redis->zAdd('k', 0, 'a');
     $this->redis->zAdd('k', 1, 'b');
     $this->redis->zAdd('k', 2, 'c');
     $this->assertTrue(2 === $this->redis->zDelete('k', 'a', 'c'));
     $this->assertTrue(1.0 === $this->redis->zScore('k', 'b'));
     $this->assertTrue($this->redis->zRange('k', 0, -1, true) == array('b' => 1.0));
     // zRange
     $this->assertTrue($z === $this->redis->zRange('key', 0, -1));
     // zScore
     $this->assertTrue(0.0 === $this->redis->zScore('key', $z[0]));
     $this->assertTrue(1.0 === $this->redis->zScore('key', $z[1]));
     $this->assertTrue(2.0 === $this->redis->zScore('key', $z[2]));
     // zRank
     $this->assertTrue(0 === $this->redis->zRank('key', $z[0]));
     $this->assertTrue(1 === $this->redis->zRank('key', $z[1]));
     $this->assertTrue(2 === $this->redis->zRank('key', $z[2]));
     // zRevRank
     $this->assertTrue(2 === $this->redis->zRevRank('key', $z[0]));
     $this->assertTrue(1 === $this->redis->zRevRank('key', $z[1]));
     $this->assertTrue(0 === $this->redis->zRevRank('key', $z[2]));
     // zIncrBy
     $this->assertTrue(3.0 === $this->redis->zIncrBy('key', 1.0, $z[2]));
     $this->assertTrue(3.0 === $this->redis->zScore('key', $z[2]));
     $this->assertTrue(5.0 === $this->redis->zIncrBy('key', 2.0, $z[2]));
     $this->assertTrue(5.0 === $this->redis->zScore('key', $z[2]));
     $this->assertTrue(2.0 === $this->redis->zIncrBy('key', -3.0, $z[2]));
     $this->assertTrue(2.0 === $this->redis->zScore('key', $z[2]));
     // mset
     $a = array('k0' => 1, 'k1' => 42, 'k2' => NULL, 'k3' => FALSE, 'k4' => array('a' => 'b'));
     $this->assertTrue(TRUE === $this->redis->mset($a));
     foreach ($a as $k => $v) {
         $this->assertTrue($this->redis->get($k) === $v);
     }
     $a = array('k0' => 1, 'k1' => 42, 'k2' => NULL, 'k3' => FALSE, 'k4' => array('a' => 'b'));
     // hSet
     $this->redis->delete('key');
     foreach ($a as $k => $v) {
         $this->assertTrue(1 === $this->redis->hSet('key', $k, $v));
     }
     // hGet
     foreach ($a as $k => $v) {
         $this->assertTrue($v === $this->redis->hGet('key', $k));
     }
     // hGetAll
     $this->assertTrue($a === $this->redis->hGetAll('key'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k0'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k1'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k2'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k3'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k4'));
     // hMSet
     $this->redis->delete('key');
     $this->redis->hMSet('key', $a);
     foreach ($a as $k => $v) {
         $this->assertTrue($v === $this->redis->hGet('key', $k));
     }
     // hMget
     $hmget = $this->redis->hMget('key', array_keys($a));
     foreach ($hmget as $k => $v) {
         $this->assertTrue($v === $a[$k]);
     }
     // getMultiple
     $this->redis->set('a', NULL);
     $this->redis->set('b', FALSE);
     $this->redis->set('c', 42);
     $this->redis->set('d', array('x' => 'y'));
     $this->assertTrue(array(NULL, FALSE, 42, array('x' => 'y')) === $this->redis->getMultiple(array('a', 'b', 'c', 'd')));
     // pipeline
     $this->sequence(Redis::PIPELINE);
     // multi-exec
     $this->sequence(Redis::MULTI);
     // keys
     $this->assertTrue(is_array($this->redis->keys('*')));
     // issue #62, hgetall
     $this->redis->del('hash1');
     $this->redis->hSet('hash1', 'data', 'test 1');
     $this->redis->hSet('hash1', 'session_id', 'test 2');
     $data = $this->redis->hGetAll('hash1');
     $this->assertTrue($data['data'] === 'test 1');
     $this->assertTrue($data['session_id'] === 'test 2');
     // issue #145, serializer with objects.
     $this->redis->set('x', array(new stdClass(), new stdClass()));
     $x = $this->redis->get('x');
     $this->assertTrue(is_array($x));
     $this->assertTrue(is_object($x[0]) && get_class($x[0]) === 'stdClass');
     $this->assertTrue(is_object($x[1]) && get_class($x[1]) === 'stdClass');
     // revert
     $this->assertTrue($this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE) === TRUE);
     // set ok
     $this->assertTrue($this->redis->getOption(Redis::OPT_SERIALIZER) === Redis::SERIALIZER_NONE);
     // get ok
 }
开发者ID:stonegithubs,项目名称:phpredis,代码行数:101,代码来源:TestRedis.php

示例6: get

 /**
  * Get a value from cache
  * @param mixed $p_mKey The Key(s)
  * @return mixed
  */
 function get($p_mKey)
 {
     return is_array($p_mKey) ? $this->_handler->getMultiple($p_mKey) : $this->_handler->get($p_mKey);
 }
开发者ID:revolveweb,项目名称:ppi-framework,代码行数:9,代码来源:Redis.php

示例7: get

 /**
  * 获取某个key值 如果指定了start end 则返回key值的start跟end之间的字符
  * @param $key string/array 要获取的key或者key数组
  * @param $start int 字符串开始index
  * @param $end int 字符串结束index
  * @return $return mixed 如果key存在则返回key值 如果不存在返回false
  */
 public static function get($key = null, $start = null, $end = null)
 {
     $redis = new \Redis();
     $redis->connect(self::_HOST, self::_PORT);
     $return = null;
     if (is_array($key) && !empty($key)) {
         $return = $redis->getMultiple($key);
     } else {
         if (isset($start) && isset($end)) {
             $return = $redis->getRange($key);
         } else {
             $return = $redis->get($key);
         }
     }
     $redis->close();
     $redis = null;
     return $return;
 }
开发者ID:skyshow,项目名称:ticket,代码行数:25,代码来源:MyRedis.class.php

示例8: Redis

<?php

$redis = new Redis();
$redis->connect("127.0.0.1", "6379");
// string
$redis->delete("KeyTime");
$redis->mset(array('key111' => "key111", "key222" => "key222"));
echo (int) $redis->exists("key111");
$array = $redis->getMultiple(array("key111", "key222"));
echo "<br>";
print_r($array);
for ($i = 0; $i < 10; $i++) {
    $redis->lpush("list", $i);
}
$redis->lpop("list");
$redis->rpop("list");
echo $redis->lsize("list");
echo $redis->lget("list", 0);
echo $redis->lset("list", 1, "new_value");
$data = $redis->lRange("list", 0, -1);
echo "<pre>";
print_r($data);
$bool = $redis->ltrim("list", 0, 5);
echo $redis->lrem("list", "5");
$bool = $redis->rpoplpush("srcKey", "dstKey");
// SET
for ($i = 0; $i < 10; $i++) {
    $redis->sadd("myset", $i + rand(10, 99));
}
$bool = $redis->srem("myset", 16);
echo (int) $bool;
开发者ID:isS,项目名称:NoSQL,代码行数:31,代码来源:redisWithPHP.php

示例9: array

var_dump($redis->decr("test1")) . '<br>';
//结果:int(8)
/**
  getMultiple

  描述:取得所有指定键的值。如果一个或多个键不存在,该数组中该键的值为假
  参数:其中包含键值的列表数组
  返回值:返回包含所有键的值的数组
*/
$arr = array('136502993', 'zhuwawa');
$int = 100;
$string = 'my love....';
$redis->set('demo2', $arr);
$redis->set('demo3', $int);
$redis->set('demo4', $string);
$result1 = $redis->getMultiple(array('demo2', 'demo3', 'demo4'));
echo '<pre>';
var_dump($result1) . '<br>';
/**
   lpush
将一个或多个值 value 插入到列表 key 的表头


描述:由列表头部添加字符串值。如果不存在该键则创建该列表。如果该键存在,而且不是一个列表,返回FALSE。
参数:key,value
返回值:成功返回数组长度,失败false
*/
$redis->delete('test');
var_dump($redis->lpush("test", "111")) . '<br>';
//结果:int(1)
var_dump($redis->lpush("test", "222")) . '<br>';
开发者ID:wujunze,项目名称:bigpan,代码行数:31,代码来源:redis.php


注:本文中的Redis::getMultiple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。