pyrate_limiter.buckets.in_memory_bucket module¶
Naive bucket implementation using built-in list
- class pyrate_limiter.buckets.in_memory_bucket.InMemoryBucket(rates)¶
Bases:
AbstractBucketSimple In-memory Bucket using native list Clock can be either time.time or time.monotonic When leak, clock is required Pros: fast, safe, and precise Cons: since it resides in local memory, the data is not persistent, nor scalable Usecase: small applications, simple logic
- is_async = False¶
- items¶
- peek(index)¶
Peek at the rate-item at a specific index in latest-to-earliest order NOTE: The reason we cannot peek from the start of the queue(earliest-to-latest) is we can’t really tell how many outdated items are still in the queue