Notes from building Ruvio
Blog
One feature or one problem per post: what it is for, the commands that do it, what it costs and where it stops.
RSS feed- Commands
- Patterns
Seven small scripts I no longer write
Moving credit between wallets, selling the last ticket, keeping the newest timestamp. Each of these used to be a short Lua script. In Ruvio each one is a single command that either does the whole job or writes nothing.
TRANSFERHTRANSFERTAKEINCRBY MAXINCR EXSET IFGT
Locks that stay safe when workers stallEvery LEASE returns a fencing token; a stale holder is rejected instead of corrupting data. - Locks
- Patterns
A lock is not enough: fencing tokens with LEASE
A lock with a TTL keeps two workers apart until one of them pauses for longer than the TTL. Here is what goes wrong then, and how the token that LEASE returns lets the protected side say no.
LEASERENEWRELEASESEMAPHOREDelayed jobs that run on timeZPOPBYSCORE and ZMOVEDUE take only the members whose time has come, in one command. - Queues
Delayed jobs without a scheduler
Send the reminder in 30 minutes, retry the webhook in 5. Two ways to do it with nothing but Ruvio: a stream entry that stays hidden until its time, and a sorted set you drain in one call.
XADD DELAYXREADGROUPXACKXAUTOCLAIMCaches without stampedesWhen a hot key expires, one caller refills it while the others wait or get the stale copy. - Caching
- Patterns
When a hot key expires: stopping cache stampedes with FILLGET
A popular cache entry expires and a thousand requests hit the database at once. FILLGET decides in one round trip who rebuilds the value, who waits, and who gets the stale copy in the meantime.
FILLGETFILLSETRetries that run onceIDEM stores the answer to a request key, so a replay returns it instead of running again. - .NET
- Integrations
The boring parts of an ASP.NET Core API, on one server
Retried POSTs that must not charge twice, per-tenant rate limits, and a cache that does not stampede. Three NuGet packages put them on Ruvio with a few lines in Program.cs.
IDEMLIMITFILLGETFILLSET
No post on this topic yet.