Sneaker and merchandise drops
Limited editions sell out in seconds without overselling a single pair.
Sell exactly the stock you have when ten thousand shoppers click Buy in the same second, and keep the bots out.
500 units go on sale.
An animated walkthrough with real HotKV commands and example replies. Click any step to jump to it.
In a flash sale the inventory database is the bottleneck exactly when it matters most. Read-then-write checks oversell under concurrency, abandoned carts lock stock forever, and bots buy the stock before real customers finish loading the page.
Stock lives in a counter that is decremented atomically, so concurrent buyers can never take more than exists. Each reservation is a key with a ten-minute expiry, a rate limit per customer slows the bots, and confirmed orders go into a stream for fulfilment to process at its own pace.
500 units go on sale.
SET stock:sneaker-x 500Each customer may try twice per 10 seconds. Bots exceed it immediately.
GCRA.LIMIT buy:customer:881 10000 2DECR is atomic. 10,000 concurrent clicks can never take more than 500 units.
DECR stock:sneaker-xThe reservation expires on its own if checkout is abandoned, and a sweeper puts the unit back.
SET hold:sneaker-x:order-7781 customer:42 NX EX 600When DECR goes below zero, the unit is returned and the shopper sees sold out. Stock never goes negative for long.
INCR stock:sneaker-xPaid orders are appended to a stream. The warehouse system works through them at its own pace.
XADD orders * order 7781 sku sneaker-x customer 42Limited editions sell out in seconds without overselling a single pair.
Seats are held for a few minutes during checkout and released automatically if the buyer leaves.
Delivery slots are counters, decremented atomically as customers book them.
DECR and INCR change stock in one step with no race.
DECRINCRBYReservations are keys with a TTL.
SETNXEXPer-customer limits with an exact retry time.
GCRA.LIMITA stream for fulfilment, with consumer groups and acknowledgements.
XADDXREADGROUPExpired holds can be noticed through keyspace notifications or a periodic sweep, which increments the stock counter again.
Yes. GET returns the current count. Only DECR reserves.
Use MULTI and EXEC, or a function, to decrement several counters together.
HotKV speaks the Redis protocol, so you can point an existing client at it and run these same commands.