OBJECT FREQ
OBJECT FREQ key
- Group
- Keys
- Complexity
- O(1)
- Arity
- 3 (exactly, counting the command name)
- HotKV Cloud
- All plans
- On-Premise
- no license needed
OBJECT FREQ returns the logarithmic access frequency counter of key, from
0 to 255, that the allkeys-lfu and volatile-lfu eviction policies use to
pick keys to evict. The counter decays over time when the key is not used.
Access frequencies are tracked only while an LFU policy is selected with
maxmemory-policy.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| The key exists | Integer: the counter | Integer |
| The key does not exist | Nil bulk string | Null |
When the eviction policy is not an LFU one, the reply is the error
ERR An LFU maxmemory policy is not selected, access frequency not tracked.
followed by a note that switching policies at runtime takes a while to settle.
Examples
Section titled “Examples”127.0.0.1:6379> CONFIG SET maxmemory-policy allkeys-lfuOK127.0.0.1:6379> SET page:home "..."OK127.0.0.1:6379> OBJECT FREQ page:home(integer) 5Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.