redis
i don't think i need to use redis on my personal projects. but i'm happy to learn.
what redis is
in-memory key-value store. super fast because everything lives in ram. often used for caching, sessions, queues.
why people love it
- crazy fast reads/writes
- simple data structures (strings, lists, sets, hashes)
- atomic operations prevent race conditions
- pub/sub messaging built-in
- persistence options available
common use cases
- cache database queries to speed up web apps
- store user sessions for web servers
- rate limiting api requests
- real-time features like chat or notifications
- job queues for background processing
when i might actually use it
maybe for a web app that gets popular and needs caching. or if i build something with real-time features.
for cloudflare workers, i'd probably use kv storage instead. for small projects, sqlite is usually enough.
redis commands i should know
- SET/GET for basic key-value
- INCR/DECR for counters
- LPUSH/RPOP for queues
- SADD/SMEMBERS for sets
- EXPIRE for ttl
architectural patterns
- cache-aside: app manages cache manually
- write-through: writes go to cache and database
- write-behind: cache writes to database later
redis vs alternatives
- memcached: simpler, just caching
- sqlite: persistent, good for small apps
- postgresql: full database features
- cloudflare kv: managed, edge distributed
redis fills the gap between simple caching and full databases. powerful tool when you need it, probably overkill for most personal projects.