pyrate_limiter.buckets.in_memory_bucket module#
Naive bucket implementation using built-in list
- class pyrate_limiter.buckets.in_memory_bucket.InMemoryBucket(rates)#
Bases:
pyrate_limiter.abstracts.bucket.AbstractBucket
Simple 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
- 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