ByteAlex
CDCloudflare Developers
•Created by ByteAlex on 7/23/2023 in #workers-help
Locking/Synchronizing Requests
Hi there!
I'm wondering if there's any simple way to acquire a lock on something with workers.
In an example:
I do have an API which carries state between 2 requests (don't ask why, it's not my API 😅).
User A sends request 1 with x = 1
User B sends request 1 with x = 2
User A sends request 2
Now user a expects his request to be fulfilled with x = 1, but x will be 2.
The solution I see here, is either to work with a queue with
max_concurrency = 1
, but that might be more overhead than just having some kind of "lock" which needs to be acquired.
What would the worker-experts recommend me to do there?
Thanks for your help!14 replies