What Is New in Redis 2.6
Redis 2.6 is a significant evolution, introducing a new Lua scripting engine, enhanced persistence options, and a variety of commands for better server introspection and client control. Here's a summary of the key changes.
| Category | Key Changes |
|---|---|
| New Features | Lua scripting, bit operations, client pause, migrate command, new persistence modes (AOF every second, AOF rewriting in background). |
| Improvements | Better replication, memory usage reporting, key expiration algorithm, configurable hash-max-ziplist, improved SORT. |
| Commands & Introspection | New commands like DEBUG OBJECT, CLIENT LIST, MONITOR, and SHUTDOWN with save option. |
| Bug Fixes & Stability | Numerous fixes for replication, memory, and edge-case behaviors. |
How does Lua scripting change the game for Redis?
The biggest shift is the inclusion of a full Lua 5.1 interpreter. This lets you run complex atomic operations directly on the server, moving logic from the client to Redis. You get atomicity and reduced network overhead in one go.
In practice, scripts like EVAL "return redis.call('GET', KEYS[1])" 1 mykey run as a single unit. This matters because you can now build custom commands, like a pop-and-push to another list, without worrying about race conditions.
What's better about persistence and replication?
You get more granular control over durability versus performance. The new appendfsync everysec AOF policy is a sensible default, and AOF rewriting now happens in the background without blocking.
For replication, partial resynchronization is more robust. Slaves can now continue serving old data while the master is down, which makes failover scenarios less disruptive for clients.
Which new commands help with debugging and operations?
A suite of commands gives you a live look inside the server. CLIENT LIST shows all connected clients, MONITOR streams all commands in real-time, and DEBUG OBJECT provides internal object metadata.
The CLIENT PAUSE command is a powerful tool for orchestration. It pauses all clients for a specified time, which is incredibly useful for testing failover or ensuring a consistent state before taking a snapshot.
Are there new data type operations?
Yes, bit-level operations on strings are a major addition. Commands like SETBIT, GETBIT, BITCOUNT, and BITOP let you use Redis as a massive bitset for analytics, bloom filters, or feature flags.
The MIGRATE command atomically moves a key from one Redis instance to another. This simplifies data sharding and rebalancing operations, removing the need for error-prone client-side transfer logic.
FAQ
Is Lua scripting production-ready in 2.6?
Yes, it's designed for production use. Scripts are atomic and are replicated to slaves in the same way as regular commands. Just be mindful of script complexity to avoid blocking the server for too long.
How does the new AOF 'everysec' policy differ from 'always'?always fsyncs after every write command, maximizing durability at a cost to performance. everysec fsyncs once per second, offering a great balance. It's the new recommended default.
Can I use BITOP for real-time analytics?
Absolutely. You can store daily user activity in bitsets and use BITOP AND to find overlapping users across days. It's fast and memory-efficient for certain types of set intersections.
What's the purpose of the CLIENT PAUSE command?
It's primarily for controlled failover testing. By pausing clients, you can ensure a slave has fully synced before promoting it, without clients writing new data to the old master during the switch.
Does the new SORT command optimization affect existing code?
No, it's fully backward compatible. The improvements are internal, making SORT ... GET patterns and sorting by external keys more efficient. Your existing queries just run faster.