Document semantics of rate limit window
From reading the code, the following comment indicates that `Redis Pattern: Rate Limiter 1` is being used which is confusing as the cache key does not contain the timestamp.
```
async def _run_pipeline(
self,
cache_key: str,
pipeline: AnyPipeline,
) -> int:
# https://redis.io/commands/incr/#pattern-rate-limiter-1
current_rate, _ = await pipeline_expire(
pipeline.incr(cache_key),
cache_key,
self._rate_spec.seconds,
).execute()
return current_rate
```
My understanding is that in-fact a variation of `Redis Pattern: Rate Limiter 2` is being used as a by-product of the `NX` command.
Is this understanding correct? If so - would be useful to update the comment.
0 条评论