DCS Redis Help Documentation

New Features of Redis 4.0

2024-05-25 01:59:37

Official Reference: https://redis.com/blog/redis-4-0-0-released/

Module

One of the biggest features in Redis 4.0.0 is the long-awaited modules system. The modules system provides an API for extending Redis with dynamically loaded modules primarily in C. The modules API provides multiple levels of APIs for developers to add new features and functionality to Redis.

With Redis Modules, developers can add new operations to existing data types, introduce new data types, such as JSON, or extend Redis with new processes like Search or Neural Network.

The new API enables developers to build extensions that were either impractical or not performant enough when built with Lua. As mentioned in the documentation for modules on Redis.io, “Redis modules make it possible to extend Redis functionality using external modules, implementing new Redis commands at a speed and with features similar to what can be done inside the core itself.”

Caching Improvements

The 4.0.0 release adds least-frequently-used (LFU) maxmemory policies giving users another algorithm for evicting keys when Redis hits the maxmemory threshold. LFU caching provides a better hit-to-miss ratio than least-recently-used (LRU) caching for many applications.

The implementation of LFU caching in Redis is done through an approximated algorithm to provide an accurate estimation of the frequency of key access without adding a significant amount of memory overhead to track the access counts. Like the current LRU caching policies, LFU caching can be applied only to volatile keys (expired keys) or to all keys.

Memory Features

The new MEMORY command gives users information into the memory consumption of a Redis instance. The MEMORY USAGE command provides users with the precise amount of memory being used by a given key, while MEMORY DOCTOR provides a framework (similar to the LATENCY DOCTOR command) for observing the overall memory consumption of an instance.

Asynchronous Delete Command

The new UNLINK command has the same functions as the DEL command but it is in the asynchronous non-blocking mode. In addition, the 'FLUSHDB' and 'FLUSHALL' commands are provided with ASYNC parameters to achieve the asynchronous non-blocking effect.

Swap Database Command

The new SWAPDB command swaps the IDs of different databases. For example, run SWAP 0 1. Database 0 becomes database 1 and database 1 changes to database 0.


y_v5dbos.KLC