unlock unlimited code runs for $79, limited time →
NOSSLETTER.techLIVE
back to archive

RED-211767 - Add BLESS — protect keys from eviction

Language: C+1696 -213feature
concepts demonstrated
Persistent key metadataCustom command implementationMemory eviction policiesCursor-based iteration (SCAN command)
The Issue & Context

Redis eviction policies remove keys when memory limits are reached, but some keys may need protection from eviction to ensure critical data persists.

Root Cause Analysis

Existing eviction mechanisms do not allow marking individual keys as protected from eviction, risking removal of important keys during memory pressure.

Solution Strategy & Architectural Pattern

Introduced a new BLESS command family to set, clear, get, and scan keys flagged as NO-EVICT, preventing their eviction under all maxmemory policies and allowing memory usage to temporarily exceed maxmemory by 25% if needed.

Key Takeaway for Contributors

BLESS enables fine-grained control over eviction by protecting critical keys, with persistence and replication support, while allowing unblessing to recover memory under pressure.