Intermediate 15 terms

Redis & Caching

Redis data structures, caching patterns, eviction policies, persistence, and distributed coordination.

  • cache hit /kæʃ hɪt/

    A request that is served directly from the cache, returning a fast response without querying the underlying database or service.

    "Our cache hit rate is 94% — only 6% of requests reach the database, which is why a small Redis instance handles traffic that would otherwise overwhelm PostgreSQL."
  • cache miss /kæʃ mɪs/

    A request for data that is not in the cache; the application must fetch it from the source and optionally store it in the cache for future requests.

    "On a cache miss we query the database, serialise the result to JSON, store it in Redis with a 60-second TTL, then return the response."
  • TTL /tiː tiː el/

    Time to Live; the duration in seconds after which a cached key expires and is automatically removed by Redis.

    "Product listings have a TTL of 300 seconds — slightly stale data is acceptable and the cache prevents thousands of identical queries per minute."
  • LRU eviction /el ɑː juː ɪˈvɪkʃən/

    Least Recently Used eviction policy; when Redis reaches its memory limit it removes the key that was accessed least recently.

    "With allkeys-lru eviction policy, Redis automatically removes cold session data when memory fills up, keeping hot data in cache."
  • Redis string /ˈredɪs strɪŋ/

    The simplest Redis data type; stores any binary-safe value up to 512MB. Used for counters, session tokens, and serialised JSON objects.

    "We store the serialised user session as a Redis string keyed by the session ID — SET, GET, and EXPIRE cover all our session management needs."
  • Redis hash /ˈredɪs hæʃ/

    Data type storing multiple field-value pairs under a single key; memory-efficient for representing objects with many attributes.

    "User profile fields are stored as a Redis hash so we can update a single field like last_seen without reserialising the entire object."
  • Redis sorted set /ˈredɪs ˈsɔːtɪd set/

    Data type where each member has a float score; members are automatically ordered by score. Used for leaderboards, rate limiting, and priority queues.

    "The global leaderboard is a Redis sorted set — ZADD scores players by their points and ZREVRANGE returns the top 10 in milliseconds."
  • pub/sub /pʌb sʌb/

    Publish/subscribe messaging; a publisher sends a message to a channel and all current subscribers receive it immediately.

    "We use Redis pub/sub to broadcast cache invalidation events across server instances so all nodes evict a stale entry simultaneously."
  • Redis Cluster /ˈredɪs ˈklʌstər/

    Redis architecture that shards data across multiple nodes using 16,384 hash slots; provides horizontal scaling and automatic failover.

    "At 50GB of session data we moved to Redis Cluster with six nodes — data is sharded automatically and a node failure triggers promotion of its replica."
  • Sentinel /ˈsentɪnəl/

    Redis high-availability solution; Sentinel processes monitor the master, detect failures, promote a replica, and update clients with the new master address.

    "Three Sentinel processes monitor our Redis master — when it failed, they reached quorum and promoted the replica within 10 seconds."
  • AOF persistence /eɪ əʊ ef pəˈsɪstəns/

    Append Only File; Redis durability mode that logs every write command. More durable than RDB snapshots but produces larger files.

    "With AOF set to everysec, we lose at most one second of writes on a crash — acceptable for our use case without the overhead of synchronous fsync."
  • cache stampede /kæʃ stæmˈpiːd/

    Also called thundering herd; occurs when many requests simultaneously hit the database after a popular cache entry expires, overwhelming the backend.

    "The homepage cache expiry at midnight caused a stampede of 8,000 simultaneous database queries — we fixed it with probabilistic early expiration and a single-writer lock."
  • write-through /raɪt θruː/

    Caching strategy where every write updates both the cache and the database synchronously; the cache always reflects the current database state.

    "Write-through caching means the cache is never stale for our user profile service — every update writes to Redis and PostgreSQL atomically."
  • cache-aside /kæʃ əˈsaɪd/

    Also called lazy loading; the application checks the cache first, and on a miss fetches from the database and populates the cache itself.

    "Cache-aside is our default pattern — the application owns cache population logic, which makes it easy to invalidate specific keys after updates."
  • distributed lock /dɪˈstrɪbjuːtɪd lɒk/

    Mechanism using Redis SETNX or the Redlock algorithm to ensure only one process across a distributed system executes a critical section at a time.

    "A Redis distributed lock prevents two cron job instances from running the same billing job simultaneously — the second instance sees the lock and exits immediately."

Ready to practice?

Test your knowledge of these terms in the interactive exercise.

Start exercise →