Enterprise-grade Redis features in Aegon including token-validated distributed locking, zero-RTT pipelining, atomic transactions, persistent Pub/Sub, and consumer-group Streams.
Beyond basic key-value caching, Aegon provides enterprise-grade abstractions over Redis: token-validated distributed locks, zero-RTT pipelining across single instances or cluster shards, atomic MULTI/EXEC transactions, persistent Pub/Sub listeners, and consumer-group event streams.
Unique Ownership Tokens: When lock() acquires the key using SET key token PX ttl NX, it generates a unique UUID token.
Atomic Safe Release: lock.release() executes an atomic Lua script:
if redis.call('GET', KEYS[1]) == ARGV[1] then return redis.call('DEL', KEYS[1])else return 0end
If the lease expires and another node acquires the lock before release() is called, the script sees mismatched tokens and avoids deleting the newer lock.
Atomic Lease Extension: lock.extend(extra_ttl) verifies token ownership via PEXPIRE inside Lua before extending the lease.
Network round-trip latency (RTT) is the primary bottleneck for Redis throughput. Command pipelining packs dozens of Redis commands into a single TCP write buffer over the event loop engine (io_uring, epoll, or IOCP), dispatching the entire batch in a single network round-trip.
When using RedisPipeline with Redis Cluster, Aegon automatically inspects the keys in the batch, groups them by their target shard pool, executes the sub-batches concurrently over the cluster nodes, and reconstructs the response vector in the original command order:
To execute multiple operations sequentially and atomically on a single Redis connection, use redis.multi():
#include <aegon/data/redis/RedisClient.h>#include <aegon/data/redis/RedisTransaction.h>using namespace aegon::data::redis;// Acquires dedicated connection guard and executes MULTIstd::optional<RedisTransaction> opt_tx = co_await redis.multi();if (!opt_tx) { throw std::runtime_error("Failed to acquire connection for transaction");}auto& tx = *opt_tx;// Queue operationstx.incr("stats:visits") .incr("stats:daily_counter");// Atomically commit via EXECstd::vector<RespValue> tx_results = co_await tx.exec();for (const auto& res : tx_results) { if (res.is_integer()) { std::println("Counter updated to: {}", res.as_integer()); }}// Or cancel pending commands if an error occurred// co_await tx.discard();
Cluster Transactions & Hash Tags
Redis Cluster requires all keys within a single MULTI/EXEC block to map to the exact same hash slot. Always use hash tags (such as user:{123}:visits and user:{123}:counter) to ensure the keys reside on the same cluster shard.