Watch all RedisConf 2021 sessions on demand
When I introduced locks and semaphores in chapter 6, I showed how locks can reduce
contention compared to WATCH/MULTI/EXEC transactions by being pessimistic in heavy
traffic scenarios. But locks themselves require two to three round trips to acquire or
release a lock in the best case, and can suffer from contention in some situations.
In this section, we’ll revisit our lock from section 6.2 and rewrite it in Lua in order
to further improve performance. We’ll then revisit our semaphore example from section
6.3 to implement a completely fair lock while also improving performance there.
Let’s first take a look at locks with Lua, and why we’d want to continue using locks
TRY REDIS ENTERPRISE CLOUD FREE
Redis Enterprise Cloud provides complete automation of day-to-day database operations. Start now with 30MB of free storage.
© 2021 Redis Labs. Redis and the cube logo are registered trademarks of Redis Labs Ltd.