asyncio-redis-rate-limit
Rate limiter for async functions using Redis as a backend.
Features
- Small and simple
- Can be used as a decorator or as a context manager
- Can be used for both clients and servers
- Works with
asyncio - Works with any amount of processes
- Works with both
redis.asyncio.client.Redisandaioredis - Free of race-conditions (hopefully!)
- Supports
redissince7.0 - Fully typed with annotations and checked with mypy, PEP561 compatible
Installation
pip install asyncio-redis-rate-limit
Extras available:
pip install asyncio-redis-rate-limit[redis]pip install asyncio-redis-rate-limit[aioredis](for python versions<3.11)
Example
As a decorator:
>>> from asyncio_redis_rate_limit import rate_limit, RateSpec
>>> from redis.asyncio import Redis as AsyncRedis # pip install redis
>>> redis = AsyncRedis.from_url('redis://localhost:6379')
>>> @rate_limit(
... rate_spec=RateSpec(requests=1200, seconds=60),
... backend=redis,
... )
... async def request() -> ...:
... ... # Do something useful! Call this function as usual.
Or as a context manager:
>>> from asyncio_redis_rate_limit import RateLimiter, RateSpec
>>> from redis.asyncio import Redis as AsyncRedis # pip install redis
>>> redis = AsyncRedis.from_url('redis://localhost:6379')
>>> async def request() -> ...:
... async with RateLimiter(
... unique_key='api-name.com',
... backend=redis,
... rate_spec=RateSpec(requests=5, seconds=1),
... ):
... ... # Do the request itself.
License
Credits
This project was generated with wemake-python-package. Current template version is: 1d63652fbb33ebe2f6d932f511b7f529a4ce2d2a. See what is updated since then.
Metadata
Release files for asyncio-redis-rate-limit 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asyncio_redis_rate_limit-1.1.0.tar.gz | 6.2 kB | Without provenance | Details for asyncio_redis_rate_limit-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asyncio_redis_rate_limit-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for asyncio_redis_rate_limit-1.1.0-py3-none-any.whl |
Total release size: 12.5 kB
Release files / asyncio_redis_rate_limit-1.1.0.tar.gz
| Download URL | asyncio_redis_rate_limit-1.1.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12b176456b07b24b2244fee258bd6e35cf9a11d67c199a1826cda9a1299b4229
|
|
BLAKE2b-256 checksum How to use checksums |
76c3994e0fef58df8545a66943139bdeb6636fedfb392a8c890e48b4e8cf45a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.0 CPython/3.11.9 Darwin/24.6.0
|
Release files / asyncio_redis_rate_limit-1.1.0-py3-none-any.whl
| Download URL | asyncio_redis_rate_limit-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6c5553b603b50073868def1bba898715b5aafbb4dbd1f80b7172115c62aedf1
|
|
BLAKE2b-256 checksum How to use checksums |
5b68c73908b3d482bc286d9611592c533d9bda680076a7a0370b0e8679f29f44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.0 CPython/3.11.9 Darwin/24.6.0
|
Security for asyncio-redis-rate-limit 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.