How to ensure the atomic operation of Redis
perpyy opened this issue · 3 comments
How does Redis get set guarantee atomicity in the cluster environment of PM2 with multiple processes
I don't know if this is a joke, but this is off-topic.
this is not a joke.
https://github.com/nestjs/throttler/blob/master/src/throttler.guard.ts
in method handleRequest
, between getRecord
and addRecord
.
In the distributed case, don't you think there will be another get / add Record between these two calls ?
If you'd made your initial description like this, then I would not have closed it.
To answer you question, no I am 99% sure there will be no problem with this. There are no other async operations being done that need to be await
ed so this process is being handled very rapidly. The current behavior works for many people, although it hasn't been tested on a cluster environment by the people who've worked on the project.
If you experience a problem with it, feel free to submit another issue.