ITADN

Document semantics of rate limit window

#134Opencpsnowden 创建于 2023-09-27
C
cpsnowdencommented
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 条评论