EVICT

Evicts the specified keys from in-memory tier and pushes them to disk if Spill is configured.

  • Since DiceDB 1.0.0
  • ACL Categories: @keyspace@write@fast

Syntax

EVICT key [key ...]

Parameters

ParameterDescriptionTypeRequired
keyOne or more keys to evict from memoryStringYes

Return Value

ConditionReturn Value
Keys evicted successfullyOK
Key does not existKey is ignored, no error is raised

Behaviour

When EVICT is called, DiceDB removes the specified keys from its in-memory store and delegates them to the configured storage backend (e.g., dicedb-spill). This is useful for tiered storage setups where you want to proactively move infrequently accessed keys out of memory to free up space.

If a key does not exist, it is silently ignored. The command accepts multiple keys in a single call for batch eviction.

Examples

Evict a single key:

127.0.0.1:7379> SET mykey "hello"
OK
127.0.0.1:7379> EVICT mykey
OK

Evict multiple keys:

127.0.0.1:7379> SET key1 "a"
OK
127.0.0.1:7379> SET key2 "b"
OK
127.0.0.1:7379> EVICT key1 key2
OK

Notes

  • This command is specific to DiceDB and is not available in Valkey or Redis.
  • The EVICT command works in conjunction with the PREMISS and PREEVICTION hooks, which enable tiered storage support through dicedb-spill.