9951 explained code solutions for 126 technologies


php-redisGet all keys from Redis list


$redis->lrange('list1', 0, -1);ctrl + c
$redis

Redis object after connection

lrange

returns specified elements from the list

list1

name of the list to get elements of

0, -1

offset and limit to use for the elements (0, -1 - get all elements from start)


Usage example

<?php

$r = new Redis(); 
$r->connect('127.0.0.1', 6379);

$r->lpush('list1', 1);
$r->lpush('list1', 2);
$r->lpush('list1', 3);

print_r($r->lrange('list1', 0, -1));
output
Array
(
    [0] => 3
    [1] => 2
    [2] => 1
)