Skip to main content
PProfileMatch
← Path

Redis · Redis Atomic Operations, Pub/Sub, Streams and Distributed Locks

0 XP
  1. 1 current stop: learning
  2. 2 upcoming
  3. 3 upcoming
  4. 4 upcoming
  5. 5 upcoming

Finish after stop 5

Stop 1 of 5 · Hackathon sign-up, noon sharp

Trick to keep in mind+3 XP

Read, check, write is three steps and two clients fit between them: make it one command.

Redis is atomic per command, not per sequence. If two requests both read 1 before either writes, both think they got the last seat. Fold the logic into one server-side operation: a DECR, or a short Lua script that refuses to go below zero. Branching on a value you just read cannot be done with queued commands alone.

Read it once, then a question tests whether the trick stuck.