OBJECT IDLETIME
OBJECT IDLETIME key
- Group
- Keys
- Complexity
- O(1)
- Arity
- 3 (exactly, counting the command name)
- HotKV Cloud
- All plans
- On-Premise
- no license needed
OBJECT IDLETIME returns the number of seconds since key was last read or
written. LRU-based eviction policies use this idle time to choose keys to
evict. Commands that only inspect a key (such as OBJECT, TYPE,
TTL and EXISTS) do not reset it, while
TOUCH does.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| The key exists | Integer: idle seconds | Integer |
| The key does not exist | Nil bulk string | Null |
While an LFU eviction policy is selected the idle time is not tracked, and the
reply is the error
ERR An LFU maxmemory policy is selected, idle time 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> SET report "q3"OK127.0.0.1:6379> OBJECT IDLETIME report(integer) 0127.0.0.1:6379> OBJECT IDLETIME report(integer) 42Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.