But it still does not solve the issue.
What if a client loses the connectivity for a long time?
Reseting the counter when the client loses connectivity is not possible too since it also requires internet connection.
Any chance it can be performed server side?
I ask if the server somehow can watch all clients connectivity to the server, and if the client is disconnected while accessing a specific counter (and locking it/holding the counter value), the server should reset the counter to 0.
If you use standard API, there is no “connectivity drop”. It is an HTTP request in and out. Once the client gets the result from an API call, the connection is not there. So when you say “client is disconnected”, I do not quite understand what that would mean given what I just described.
If your suggestion is to wait until the client receives back a valid internet connectivity, then the object would be locked for unknown period.
That’s correct if you use the Caching API, you can set an expiration date for the value, so it is automatically cleaned up.
that would interrupt the operation which is currently running. when many clients are relying and waiting a counter, if somehow the cache expires that “counter/lock” value, then it would get messy.