Redis 4.0 Unveiled: New Module System, PSYNC Enhancements, LFU Cache & More
Redis 4.0 introduces a groundbreaking module system for custom data types, improves replication with tag‑based PSYNC, adds an LFU eviction policy, provides non‑blocking UNLINK deletion, and expands memory introspection commands, collectively enhancing performance, flexibility, and extensibility of this popular in‑memory database.
Introduction
Redis 4.0 is about to be released, a major version with significant changes; here are several key new features.
Module System Introduced
The new module system allows custom extensions to Redis, enabling developers to create their own data types and functionalities.
For example, the Redis author has implemented a neural‑network data type, and others have built rate‑limiting commands, graph databases, secondary indexes, time‑series, full‑text search, and more.
With the module system, Redis can evolve beyond a simple database or cache; it could serve as a network server or a foundational protocol for various extensions.
Improved Replication Strategy
Previously, Redis used a fully synchronous replication: the master generated an RDB file, transferred it, and the slave loaded it.
Redis 4.0 introduces PSYNC with partial synchronization, where master and slave maintain replication offsets; after a disconnection, they can resume replication from the offset without a full sync.
PSYNC improves replication performance but has limitations during failover when a slave becomes master and other slaves lack offset records, requiring a full sync.
Version 4.0 adds a tag label combined with the offset, stored in the RDB file, so each slave records the tag and offset, enabling PSYNC‑based partial resynchronization even after a slave is promoted to master.
Cache Eviction Optimization
Memory is limited, and efficient cache reclamation is critical. Redis 4.0 refines the existing eviction strategy to be more robust, fast, and precise.
A new LFU (Least Frequently Used) policy is added to evict the least frequently accessed keys.
Non‑Blocking Deletion
The new UNLINK command performs a non‑blocking delete: it removes the key reference immediately and frees the memory asynchronously in a separate thread.
New MEMORY Commands
The MEMORY command suite provides detailed insight into memory usage, including:
Inspecting memory consumption of a specific key.
Viewing detailed memory usage breakdown.
Requesting memory release.
Examining internal allocator state.
Conclusion
The module system represents a major architectural shift, expanding Redis’s application scenarios, while the other enhancements boost performance and efficiency.
Beyond these highlights, Redis 4.0 includes additional features, making the upcoming release highly anticipated; the release candidate is already available, and the final version is imminent.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
