redis OBJECT command


  Translation results:

英[ˈɒbdʒɪkt] US[ˈɑ:bdʒekt]

##n.Object; target; object; object, object

vi.Disapprove, oppose; feel disgusted

vt. Reasons for objection

Third person singular: objects Plural: objects Present participle: objecting Past tense: objected Past participle: objected

redis OBJECT commandsyntax

Function: The OBJECT command allows viewing the Redis object of a given key from within.

Syntax: OBJECT subcommand [arguments [arguments]]

Description: It is usually used for debugging or understanding in order to save space And the case of using special encoding for key. When using Redis as a cache program, you can also determine key eviction policies through the information in the OBJECT command.

Available versions: >= 2.2.3

Time complexity: O(1)

Returns: REFCOUNT and IDLETIME return numbers. ENCODING returns the corresponding encoding type.

redis OBJECT commandexample

redis> SET game "COD"           # 设置一个字符串
OK
redis> OBJECT REFCOUNT game     # 只有一个引用
(integer) 1
redis> OBJECT IDLETIME game     # 等待一阵。。。然后查看空转时间
(integer) 90
redis> GET game                 # 提取game, 让它处于活跃(active)状态
"COD"
redis> OBJECT IDLETIME game     # 不再处于空转
(integer) 0
redis> OBJECT ENCODING game     # 字符串的编码方式
"raw"
redis> SET phone 15820123123    # 大的数字也被编码为字符串
OK
redis> OBJECT ENCODING phone
"raw"
redis> SET age 20               # 短数字被编码为 int
OK
redis> OBJECT ENCODING age
"int"

Popular Recommendations

Home

Videos

Q&A