I'm looking at the source for the redis-rate-limiter library here on line 11.
Going through the exec, using "10/minute" rate/duration:
ratelimittemp:ID to 0 and set to expire in 60 secondsratelimit:IDratelimit:IDWhat's the point of a rename here?
It's a way to refresh the rate limiter counter. It renames the temp key to real key if the real key does not exist, i.e. renamenx.
If the real key exists, increase the current counter, and see if we reach the rate limit of current time window. However, if the real key does not exist, it means the the previous time window, e.g. 1 minute, has been passed, and we need to start a new time window, i.e. a new counter. So we rename the temp key (with time window as expiration) to the real key, and increase on this new real key.