Dragonfly

Question: How can you check the eviction policy in Redis?

Answer

In Redis, the eviction policy dictates how keys are removed when the database reaches its maximum memory limit. To check the current eviction policy, you can use the CONFIG GET command with the argument maxmemory-policy.

Here's an example of how to do this from a Redis client:

127.0.0.1:6379> CONFIG GET maxmemory-policy
1) "maxmemory-policy"
2) "allkeys-lru"

This command will return the currently set eviction policy along with the policy name. The possible eviction policies are:

Each of these policies has their own trade-offs, so it's important to select one that fits your application's needs.

Was this content helpful?

Other Common Redis Questions (and Answers)

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost