Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Mget command

Redis Mget command

Redis string

The Redis Mget command returns the values of all (one or more) given keys. If a given key does not exist, that key returns the special value nil.

Syntax

The basic syntax of the redis Mget command is as follows:



redis 127.0.0.1:6379> MGET KEY1 KEY2 .. KEYN

Available Version

= 1.0.0

Return Value

A list containing the values of all given keys.

Example



redis 127.0.0.1:6379> SET key1 "hello"

OK

redis 127.0.0.1:6379> SET key2 "world"

OK

redis 127.0.0.1:6379> MGET key1 key2 someOtherKey

1) "Hello"

2) "World"

3) (nil)

Redis string