Metadata-Version: 2.4
Name: reche
Version: 0.1.2
Summary: Reche (Redis Cache) is a Python library that provides a simple interface for caching data in Redis.
Project-URL: Code, https://gitlab.com/Randommist/reche
Project-URL: Homepage, https://gitlab.com/Randommist/reche
Project-URL: Issues, https://gitlab.com/Randommist/reche/-/issues
Author-email: Randommist <andrey18s@yandex.ru>
License-Expression: MIT
License-File: LICENSE
Keywords: async,cache,decorator,redis
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: redis>=5.2.1
Description-Content-Type: text/markdown

# Reche (Redis Cache)

> Python библиотека, которая предоставляет декоратор для кэширования результатов функций в Redis, поддерживая различные форматы сериализации и стратегии кэширования, а также асинхронные операции.

## Установка

---

### 📥 Установка из Git-репозитория

#### Для pip
```bash
pip install git+https://gitlab.com/Randommist/reche.git
```

#### Для uv
```bash
uv add git+https://gitlab.com/Randommist/reche.git
```

#### Для poetry
```bash
poetry add git+https://gitlab.com/Randommist/reche.git
```

---

### 📦 Установка из PyPI

#### Для pip
```bash
pip install reche
```

#### Для uv
```bash
uv add reche
```

#### Для poetry
```bash
poetry add reche
```

---

## Использование (sync)
```python
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)
```python
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())
```
