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


PHP Redis::lrange方法代码示例

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


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

示例1: it_can_lrange

 public function it_can_lrange()
 {
     $this->redis->lrange('test', 0, 10)->shouldBeCalled()->willReturn(['test']);
     $this->lRange('test', 0, 10)->shouldReturn(['test']);
     $this->redis->lrange('test', 0, 10)->willThrow(new \RedisException());
     $this->shouldThrow(DriverException::class)->during('lRange', ['test', 0, 10]);
 }
开发者ID:mgdigital,项目名称:busque,代码行数:7,代码来源:PHPRedisAdapterSpec.php

示例2: index

 /**
  * 主界面
  */
 public function index()
 {
     if (Auth::check()) {
         $cartkey = Auth::user()->front_uid;
     } else {
         $cartkey = $this->getIP();
     }
     $key = 'laravel:user:' . $cartkey . ':cart';
     $shop_id = Redis::lrange($key, 0, 0);
     $ids = array_count_values(Redis::lrange($key, 1, -1));
     $shop = Shop::find($shop_id[0]);
     $cart_list = array();
     $cart_amount = 0;
     // 商品总价格
     $i = 0;
     foreach ($ids as $id => $amount) {
         $good = Menu::find($id);
         $cart_list[$i] = array('good_name' => $good->title, 'good_id' => $id, 'good_price' => $good->price, 'good_amount' => $amount, 'good_total' => $good->price * $amount);
         $cart_amount += $cart_list[$i]['good_total'];
         $i++;
     }
     $output = array('userbar' => $this->getUserBar(), 'deliver_place' => Session::get('deliver_place'), 'deliver_tel' => Session::get('deliver_tel'), 'deliver_name' => Session::get('deliver_name'), 'deliver_time' => array('08:00', '09:00', '10:12', '12:30'), 'data' => array('user_name' => '注释用户名', 'shop_path' => '', 'shop_id' => $shop->id, 'shop_logo' => $shop->pic, 'shop_name' => $shop->name, 'shop_href' => url('shop/' . $shop->id), 'shop_type' => $shop->type, 'cart_list' => $cart_list, 'cart_amount' => $cart_amount, 'deliver_place' => Session::get('deliver_place'), 'deliver_time' => array('08:00', '09:00', '10:12', '12:30'), 'pay_method' => array('0' => array('is_default' => 0, 'method_name' => '在线支付'))), 'pay_status' => '付款信息');
     //var_dump($output);
     return View::make("template.order.order")->with($output);
 }
开发者ID:andycall,项目名称:haochigou,代码行数:28,代码来源:CheckoutController.php

示例3: info

 public function info()
 {
     //phpinfo();
     $redis = new Redis();
     $redis->connect(REDIS_HOST, REDIS_PORT);
     $redis->auth(REDIS_AUTH);
     $chat_data = $redis->lrange("chat:orFu-vgK-snskoQdDgMkBe-jFe1k:2", 0, -1);
     var_dump($chat_data);
 }
开发者ID:binshen,项目名称:website,代码行数:9,代码来源:test.php

示例4: testRawCommand

 public function testRawCommand()
 {
     $this->redis->set('mykey', 'some-value');
     $str_result = $this->redis->rawCommand('get', 'mykey');
     $this->assertEquals($str_result, 'some-value');
     $this->redis->del('mylist');
     $this->redis->rpush('mylist', 'A', 'B', 'C', 'D');
     $this->assertEquals($this->redis->lrange('mylist', 0, -1), array('A', 'B', 'C', 'D'));
 }
开发者ID:Jerry-Shaw,项目名称:phpredis,代码行数:9,代码来源:RedisTest.php

示例5: update_weixin_user

 public function update_weixin_user($openid, $broker_id)
 {
     $this->api_model->update_weixin_user($openid);
     $redis = new Redis();
     $redis->connect(REDIS_HOST, REDIS_PORT);
     $redis->auth(REDIS_AUTH);
     $key = "map:" . $broker_id;
     $users = $redis->lrange($key, 0, -1);
     if (!in_array($openid, $users)) {
         $redis->lpush($key, $openid);
     }
 }
开发者ID:binshen,项目名称:website,代码行数:12,代码来源:api.php

示例6: getChart

 /**
  * 获取首页图表数据
  */
 public function getChart()
 {
     $shop_id = Auth::user()->shop_id;
     $output = array('success' => 'true', 'state' => 200, 'errMsg' => '', 'no' => 0, 'data' => array());
     $monStr = array('一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月');
     $output['data']['month'] = array_slice($monStr, date('m', strtotime('now')) - 6, 6);
     $output['data']['goods'] = array();
     $menus = Shop::find($shop_id)->menus;
     foreach ($menus as $menu) {
         $key = 'laravel:menu:' . $menu->id . ':sold:month';
         array_push($output['data']['goods'], array('goods_id' => $menu->id, 'goods_name' => $menu->title, 'goods_sails' => Redis::lrange($key, 0, 5)));
     }
     return Response::json($output);
 }
开发者ID:andycall,项目名称:map_admin_RD,代码行数:17,代码来源:HomeController.php

示例7: testRename

 public function testRename()
 {
     // strings
     $this->redis->delete('key0');
     $this->redis->set('key0', 'val0');
     $this->redis->renameKey('key0', 'key1');
     $this->assertTrue($this->redis->get('key0') === FALSE);
     $this->assertTrue($this->redis->get('key1') === 'val0');
     // lists
     $this->redis->delete('key0');
     $this->redis->lPush('key0', 'val0');
     $this->redis->lPush('key0', 'val1');
     $this->redis->renameKey('key0', 'key1');
     $this->assertTrue($this->redis->lGetRange('key0', 0, -1) === array());
     $this->assertTrue($this->redis->lGetRange('key1', 0, -1) === array('val1', 'val0'));
     // variadic
     $this->redis->delete('key0');
     $this->assertTrue(3 === $this->redis->lPush('key0', 'val0', 'val1', 'val2'));
     $this->assertTrue(array('val2', 'val1', 'val0') === $this->redis->lrange('key0', 0, -1));
     $this->redis->delete('key0');
     $this->assertTrue(3 === $this->redis->rPush('key0', 'val0', 'val1', 'val2'));
     $this->assertTrue(array('val0', 'val1', 'val2') === $this->redis->lrange('key0', 0, -1));
 }
开发者ID:stonegithubs,项目名称:phpredis,代码行数:23,代码来源:TestRedis.php

示例8: range

 public function range($start, $length = null)
 {
     $end = is_null($length) ? -1 : $start + $length;
     return $this->redis->lrange($this->key, $start, $end);
 }
开发者ID:justthefish,项目名称:hesper,代码行数:5,代码来源:RedisNoSQLList.php

示例9: getUserBarCart

 public function getUserBarCart()
 {
     if (Auth::check()) {
         $cartkey = Auth::user()->front_uid;
     } else {
         $cartkey = $this->getIP();
     }
     $key = 'laravel:user:' . $cartkey . ':cart';
     if ($shop_id = Redis::lindex($key, 0)) {
         $data['successs'] = 'true';
         $data['state'] = 200;
         $data['errMsg'] = '';
         $data['no'] = 0;
         $shop = Shop::find($shop_id);
         $data['data']['url'] = 'shop/' . $shop_id;
         $data['data']['shop_name'] = $shop->name;
         $data['data']['all_value'] = 0;
         $data['data']['state'] = $shop->state == 0 ? 0 : 1;
         if ($shop->state == 1) {
             $data['data']['state_msg'] = '店铺打烊了';
         } elseif ($shop->state == 2) {
             $data['data']['state_msg'] = '店铺太忙了';
         } else {
             $data['data']['state_msg'] = '';
         }
         $ids = array_count_values(Redis::lrange($key, 1, -1));
         $data['data']['goods'] = array();
         foreach ($ids as $id => $count) {
             $menu = Menu::find($id);
             $value = $menu->price * $count;
             $data['data']['all_value'] += $value;
             array_push($data['data']['goods'], array('good_name' => $menu->title, 'good_value' => $value, 'good_count' => $count));
         }
         return Response::json($data);
     } else {
         return array('success' => 'false', 'state' => 200, 'errMsg' => '', 'no' => 0, 'data' => array());
     }
 }
开发者ID:andycall,项目名称:haochigou,代码行数:38,代码来源:ShopController.php

示例10: choose_broker

 public function choose_broker($id, $o_bid)
 {
     $wx_user = $this->house_model->choose_broker($id);
     if (!empty($wx_user)) {
         $open_id = $wx_user['open_id'];
         $broker_id = $wx_user['broker_id'];
         $this->api_model->update_weixin_user($open_id);
         $this->session->set_userdata('rel_name', $wx_user['rel_name']);
         $this->session->set_userdata('wx_broker_id', $broker_id);
         if ($broker_id != $o_bid) {
             $redis = new Redis();
             $redis->connect(REDIS_HOST, REDIS_PORT);
             $redis->auth(REDIS_AUTH);
             if (!empty($o_bid)) {
                 $o_key = "map:" . $o_bid;
                 $redis->lrem($o_key, $open_id, 0);
             }
             $key = "map:" . $broker_id;
             $users = $redis->lrange($key, 0, -1);
             if (!in_array($open_id, $users)) {
                 $redis->lpush($key, $open_id);
             }
         }
     }
     $this->view_list(1);
 }
开发者ID:binshen,项目名称:website,代码行数:26,代码来源:b_house.php

示例11: getRedis

function getRedis($key)
{
    $redis = new Redis();
    $redis->connect(HOST_REDIS, 6379);
    return $redis->lrange($key, 0, 4);
}
开发者ID:maxca,项目名称:Multiple-processing-php,代码行数:6,代码来源:Multiprocessing-php-with-redis.php

示例12: Redis

<?php

header("Content-type:text/html;charset=utf-8");
$username = $_POST['username'];
$phone = $_POST['phone'];
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$begin_time = time();
for ($i = 0; $i < 5000; $i++) {
    $redis->set('username' . $i, $username);
    $redis->set('phone' . $i, $phone);
    $redis->lpush("tutorial-list", "Redis" . $i);
}
$arList = $redis->lrange("tutorial-list", 0, 1000);
echo "Stored string in redis:: ";
print_r($arList);
$end_time = time();
echo $end_time - $begin_time;
开发者ID:iamzcr,项目名称:iamzcr-code,代码行数:18,代码来源:redis_set.php

示例13: Redis

<?php

$redis = new Redis();
$redis->connect('192.168.0.34', 6379);
//$redis->set('goods_count',10);
echo $redis->get('goods_count');
//$redis->delete('userlist');
//
$userList = array();
$userArr = $redis->lrange('userlist', 0, -1);
foreach ($userArr as $key => $user) {
    $userList[$key] = json_decode($user, true);
}
var_dump($userList);
开发者ID:sunlyliuh,项目名称:myproject,代码行数:14,代码来源:redis.php


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