修改本页
Redis

OBJECT subcommand [arguments [arguments ...]]

The OBJECT command allows to inspect the internals of Redis Objects associated with keys. It is useful for debugging or to understand if your keys are using the specially encoded data types to save space. Your application may also use the information reported by the OBJECT command to implement application level key eviction policies when using Redis as a Cache.

The OBJECT command supports multiple sub commands:

Objects can be encoded in different ways:

All the specially encoded types are automatically converted to the general type once you perform an operation that makes it impossible for Redis to retain the space saving encoding.

返回值

Different return values are used for different subcommands.

If the object you try to inspect is missing, a null bulk reply is returned.

例子

redis> lpush mylist "Hello World"
(integer) 4
redis> object refcount mylist
(integer) 1
redis> object encoding mylist
"ziplist"
redis> object idletime mylist
(integer) 10

In the following example you can see how the encoding changes once Redis is no longer able to use the space saving encoding.

redis> set foo 1000
OK
redis> object encoding foo
"int"
redis> append foo bar
(integer) 7
redis> get foo
"1000bar"
redis> object encoding foo
"raw"
Comments powered by Disqus