THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class MemoryRateLimitStore: (source)
Constructor: MemoryRateLimitStore(max_keys, max_events)
Track rate-limit counters in process-local memory.
| Method | __at |
Report whether admitting a new client would exceed either bound. |
| Method | __gc |
Inspect the next group of keys and remove expired buckets. |
| Method | __hit |
Update quota and capacity counters while holding the store lock. |
| Method | __init__ |
Initialize an empty rate-limit store. |
| Method | __new |
Create a bucket only when bounded reclamation makes room for it. |
| Async Method | hit |
Record a request attempt and decide whether it is allowed. |
| Constant | _GC |
Gc batch size value used by MemoryRateLimitStore. |
| Constant | _GC |
Inspect a bounded group of keys after each group of request attempts. |
| Class Variable | __slots__ |
Declare the instance attribute slots reserved by this class. |
| Instance Variable | __keys |
Keys produced by deque. |
| Instance Variable | __lock |
Lock protecting concurrent access to shared state. |
| Instance Variable | __max |
Maximum number of accepted timestamps retained across all clients. |
| Instance Variable | __max |
Maximum number of retained client buckets. |
| Instance Variable | __storage |
Entries retained by the in-memory storage backend. |
| Instance Variable | __ticks |
Ticks value used by MemoryRateLimitStore. |
| Instance Variable | __total |
Total events value used by MemoryRateLimitStore. |
Report whether admitting a new client would exceed either bound.
| Returns | |
bool | Whether client or timestamp capacity is exhausted. |
Create a bucket only when bounded reclamation makes room for it.
| Parameters | |
key:str | Client identity to retain. |
now:float | Current monotonic timestamp. |
window:int | Sliding-window duration in seconds. |
| Returns | |
orionis.http.layer.store.memory_rate_limit._RateLimitBucket | None | New empty bucket, or None when the store cannot retain more clients. |
Record a request attempt and decide whether it is allowed.
Implements a sliding window over accepted attempts. Inactive keys are reclaimed incrementally during subsequent attempts, including rejected attempts. Each key should use a consistent window. A lock serializes updates across event loops and threads. Capacity exhaustion rejects attempts without evicting active quotas or retaining rejected clients.
| Parameters | |
key:str | Unique identifier for the rate-limited entity (e.g. IP, user id, route). |
limit:int | Maximum number of requests allowed within window. |
window:int | Length of the sliding window in seconds. |
| Returns | |
bool | True when the request is within the limit, False when the quota is exceeded. |