Reche (Redis Cache) is a Python library that provides a simple interface for caching data in Redis.
Project description
Reche (Redis Cache)
Python библиотека, которая предоставляет декоратор для кэширования результатов функций в Redis, поддерживая различные форматы сериализации и стратегии кэширования, а также асинхронные операции.
Установка
📥 Установка из Git-репозитория
Для pip
pip install git+https://gitlab.com/Randommist/reche.git
Для uv
uv add git+https://gitlab.com/Randommist/reche.git
Для poetry
poetry add git+https://gitlab.com/Randommist/reche.git
📦 Установка из PyPI
Для pip
pip install reche
Для uv
uv add reche
Для poetry
poetry add reche
Использование (sync)
import time
import redis
from reche import RedisCache
redis_client = redis.Redis(host="localhost", port=6379, db=0)
redis_cache = RedisCache(redis_client)
@redis_cache.cache()
def sum(a: int, b: int) -> int:
time.sleep(3)
return a + b
result = sum(1, 2) # ожидание 3 секунды
print(result)
result = sum(1, 2) # моментально
print(result)
Использование (async)
import asyncio
import redis.asyncio as redis
from reche import RedisCache
redis_client = redis.Redis(host="localhost", port=6379, db=0)
redis_cache = RedisCache(redis_client)
@redis_cache.cache()
async def sum(a: int, b: int) -> int:
await asyncio.sleep(3)
return a + b
async def main():
result = await sum(1, 2) # ожидание 3 секунды
print(result)
result = await sum(1, 2) # моментально
print(result)
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
reche-0.1.2.tar.gz
(10.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
reche-0.1.2-py3-none-any.whl
(4.5 kB
view details)
File details
Details for the file reche-0.1.2.tar.gz.
File metadata
- Download URL: reche-0.1.2.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfecab9e283bea60dd30f90a8161898b6c8a07cacfe8285e0c02e84ad9bb8e49
|
|
| MD5 |
eccdc83e74d80e8835a14b8c67f48114
|
|
| BLAKE2b-256 |
4ecd59435e861f62edff9683997723a4eb4b3e06887fc167221c80ea70e4598f
|
File details
Details for the file reche-0.1.2-py3-none-any.whl.
File metadata
- Download URL: reche-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c320a7a074e74596d9866eeb5a02fe68f24dbed8872f1d5fd4ea9d0be0eea800
|
|
| MD5 |
66a8fefadabea7fad734c6be4a2c689d
|
|
| BLAKE2b-256 |
65ac89ef850fbc42722e17e53a9d8e4bc3607da5a9babd249fe79574d854aeb5
|