OBJECT ENCODING
OBJECT ENCODING key
- Group
- Keys
- Complexity
- O(1)
- Arity
- 3 (exactly, counting the command name)
- HotKV Cloud
- All plans
- On-Premise
- no license needed
OBJECT ENCODING returns the name of the encoding used for the value at
key. Small collections use a compact encoding and switch to a general one
once they grow past the configured size limits; tools written for Redis that
check these names keep working.
| Type | Possible encodings |
|---|---|
| String | int (a 64-bit integer), embstr, raw |
| List | listpack, quicklist |
| Set | intset, listpack, hashtable |
| Hash | listpack, listpackex (compact, with field expiry), hashtable |
| Sorted set | listpack, skiplist |
| Stream | stream |
| Bloom filter, count-min sketch, Top-K | raw |
Looking at a key with OBJECT is not an access to it.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| The key exists | Bulk string: the encoding name | Bulk string |
| The key does not exist | Nil bulk string | Null |
Examples
Section titled “Examples”127.0.0.1:6379> SET counter 12345OK127.0.0.1:6379> OBJECT ENCODING counter"int"127.0.0.1:6379> SET name "ada"OK127.0.0.1:6379> OBJECT ENCODING name"embstr"127.0.0.1:6379> SADD ids 1 2 3(integer) 3127.0.0.1:6379> OBJECT ENCODING ids"intset"127.0.0.1:6379> OBJECT ENCODING missing(nil)Compatibility
Section titled “Compatibility”Same encoding names as Redis 7.4. The probabilistic types report raw.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.