Working with Object Inspection

1. Getting Object Encoding

CommandPurpose
OBJECT ENCODING keyInternal representation (varies by size/type)

2. Getting Object Frequency

CommandRequires
OBJECT FREQ keyLFU policy (allkeys-lfu/volatile-lfu)

3. Getting Object Idle Time

CommandRequires
OBJECT IDLETIME keyLRU policy; seconds since last access

4. Getting Object Reference Count

CommandDescription
OBJECT REFCOUNT keyInternal refcount; shared integers return large values

5. Getting Object Help

OBJECT HELP
SubcommandLists
OBJECT HELPAll OBJECT subcommands with descriptions

6. Understanding Internal Encodings

TypeEncodings
Stringint, embstr (≤44 bytes), raw
Listlistpack (small), quicklist
Hashlistpack, hashtable
Setintset, listpack, hashtable
Sorted Setlistpack, skiplist
Streamstream (radix tree of listpacks)

7. Understanding List Encodings

SettingDefaultEffect
list-max-listpack-size-2 (8KB)Per-node size; negative = bytes
list-compress-depth0Compress quicklist interior nodes

8. Understanding Hash Encodings

SettingDefaultEffect
hash-max-listpack-entries128Threshold → switch to hashtable
hash-max-listpack-value64Max element byte size

9. Understanding Set Encodings

SettingDefaultEffect
set-max-intset-entries512All-int sets → intset
set-max-listpack-entries128Mixed small sets → listpack
set-max-listpack-value64Max value byte size in listpack

10. Understanding Sorted Set Encodings

SettingDefaultEffect
zset-max-listpack-entries128Switch threshold to skiplist
zset-max-listpack-value64Max element byte size
Note: Keep aggregates small to retain compact encodings — large memory savings vs hashtable/skiplist.