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
# 數(shù)據(jù)庫不為空 redis> MSET fruit "apple" drink "beer" food "cookies" # 設(shè)置多個 key OK redis> RANDOMKEY "fruit" redis> RANDOMKEY "food" redis> KEYS * # 查看數(shù)據(jù)庫內(nèi)所有key,證明 RANDOMKEY 并不刪除 key 1) "food" 2) "drink" 3) "fruit" # 數(shù)據(jù)庫為空 redis> FLUSHDB # 刪除當(dāng)前數(shù)據(jù)庫所有 key OK redis> RANDOMKEY (nil)