-
-
Notifications
You must be signed in to change notification settings - Fork 8
Description
We should use a rolling window for the reset time instead of basing it off the latest request.
Using a sorted set should allow us to implement that without wasting too much performance. When an interaction is registered, the time at which the request isn't counted anymore (time() + LIMITS.units) should be inserted inside the set corresponding to the user/route pair (the current key can be kept). This correspond to a ZADD operation.
When the remaining interactions should be counted, a ZREMRANGEBYSCORE operation should be used to clear entries from 0 to the current timestamp. ZCOUNT can be used to know the amount of interactions that has been already done.
The current TTL behavior should be kept to hopefully clear entries when the client stops.
This arise the question of what should requests-reset return. Should it be whenever the first interaction resets?