Redis provides several mechanisms for distributing data and coordinating concurrent access. Replication involves asynchronous copies from a primary to one or more replica nodes, which both scales reads and improves availability. For stronger write guarantees, the WAIT command blocks the client until a specified number of replicas have acknowledged the write. Sentinel is a built-in high-availability system that monitors primaries and replicas and performs automatic failover when the primary becomes unreachable. For horizontal scaling, Redis Cluster is a native sharding solution that splits the keyspace across nodes using 16,384 hash slots, with each key mapped by \(\text{CRC16}(key) \bmod 16384\). When a multi-key command touches keys in different slots, Redis returns a CROSSSLOT error. To force related keys into the same slot, a substring can be enclosed in curly braces, a feature called a hash tag.
When a slot is being migrated, clients may receive two different redirection errors. A MOVED response is permanent and tells the client that the requested slot is now owned by a different node, so the client should update its routing table. An ASK response is transient and is only valid during the migration itself, hinting that the key may still be on the source node for this particular request. A recommended production topology for Redis Cluster is three masters with one replica each, for a total of six nodes, which tolerates the loss of a single master while remaining manageable. Atomicity across multiple commands is provided by transactions: MULTI starts a transaction, EXEC executes the queued commands atomically and in isolation from other clients, and WATCH provides optimistic concurrency by aborting the transaction if any watched key is modified before EXEC. Lua scripts, invoked with EVAL or with EVALSHA by their SHA1 hash, also run atomically and additionally support conditional logic and complex cross-key operations. If EVALSHA cannot find the script in the cache, the server returns a NOSCRIPT error, and clients should fall back to EVAL to re-cache it.
Operational commands round out the Redis toolbox. SCAN iterates over the keyspace using a cursor in small batches and is safe on large datasets, whereas KEYS returns all matches in a single blocking call and should be avoided in production. Inside SCAN, MATCH filters returned keys by a glob pattern. The TYPE command reports the data type stored at a key, while OBJECT ENCODING reveals the internal encoding, such as embstr for small strings up to 44 bytes stored inline in the Redis object, int for small integers, listpack for small lists and hashes, skiplist for sorted sets, or hashtable for larger collections. OBJECT IDLETIME returns the seconds since a stored object was last accessed. The SLOWLOG records commands that exceeded a configurable time threshold, which is invaluable for diagnosing performance issues. Finally, the INFO command provides a comprehensive set of server statistics and configuration values, including used_memory, the total bytes Redis has allocated to store data including overhead.