More than a cache
In the server software landscape, the cache is traditionally a simple layer: key-value pairs in memory to avoid repeated database lookups. Memcached has dominated this space for years with a deliberately minimal model. In 2009 Salvatore Sanfilippo, an Italian developer, releases Redis (Remote Dictionary Server) with a different ambition: to build an in-memory data structure server that goes well beyond simple caching.
Redis operates entirely in RAM, which guarantees latencies in the order of microseconds for read and write operations. But the fundamental difference from traditional caches lies in the supported data types.
Native data structures
Redis does not handle only strings. The server natively supports lists (ordered sequences with push and pop from both ends), sets (unordered collections with union, intersection and difference operations), hashes (field-value maps, ideal for representing objects), and sorted sets — ordered collections where each element has a numeric score determining its position.
Every operation on these structures is atomic: in a concurrent environment, no explicit locks are needed because Redis is single-threaded and processes one command at a time. This architectural simplicity eliminates entire classes of concurrency-related bugs.
The pub/sub mechanism allows clients to subscribe to channels and receive messages in real time, turning Redis into a lightweight messaging system. The EXPIRE and TTL commands allow setting an expiration on any key, useful for temporary sessions and rate limiting.
Optional persistence
Despite being an in-memory database, Redis offers two persistence mechanisms to disk: RDB (periodic snapshots of the entire dataset) and AOF (Append Only File, which logs every write operation). The operator can choose the trade-off between performance and durability based on the use case.
This versatility opens scenarios that traditional caches do not cover: job queues (lists as FIFO queues), real-time leaderboards (sorted sets with scores), user session management, atomic counters for rate limiting, and uniqueness filters based on sets.
Redis is released under the BSD licence and written in ANSI C, with no external dependencies. A single binary, one configuration file, and a server ready in seconds.
Link: redis.io
