## Notes [Redis - YouTube](https://www.youtube.com/watch?v=p-88GN1WVs8&list=PLCRMIe5FDPsd0gVs500xeOewfySTsmEjf&index=9) ## What and Why - Initially used as a cache - Values can be strings, hashes, lists, sets, sorted sets - Sharding distributes the cache load among cluster nodes ## Use Cases ### Session Storage Used for storing session data among stateless servers. 1. User uses web app 2. Web app sends data to server 3. Server caches data in Redis 4. Redis sends back a session ID in a cookie ### Distributed Lock Using a distributed lock would be good for the following cases, generally where multiple actors try to perform the same piece of work. These cases are grouped between *efficiency* and *correctness*. - Maintaining request counters per IP address (rate limiting) - Distinct IP addresses per user (abuse detection) ### Leaderboard Backed by a sorted set