random
UK[ˈrændəm] US[ˈrændəm]
adj.Random; arbitrary; random
n.Random; Accidental action
key
UK[ki:] US[ki]
n.Key; (of a typewriter, etc.) key; key, clue, secret; (of music) key
vt. Type; lock; adjust the tone of...; provide clue
vi. use key
adj. key; Main
Third person singular: keys Plural: keys Present participle: keying Past tense: keyed Past participle: keyed
redis RANDOMKEY command syntax
Function: Randomly return (without deleting) a key from the current database.
Syntax: RANDOMKEY
Description: >= 1.0.0
Time complexity: O(1)
Return: When the database is not empty, return a key. When the database is empty, nil is returned.
redis RANDOMKEY command example
# 数据库不为空 redis> MSET fruit "apple" drink "beer" food "cookies" # 设置多个 key OK redis> RANDOMKEY "fruit" redis> RANDOMKEY "food" redis> KEYS * # 查看数据库内所有key,证明 RANDOMKEY 并不删除 key 1) "food" 2) "drink" 3) "fruit" # 数据库为空 redis> FLUSHDB # 删除当前数据库所有 key OK redis> RANDOMKEY (nil)