Metadata-Version: 2.4
Name: classic-cache
Version: 1.2.1
Summary: Provides cache utils
Author-email: Sergey Variasov <variasov@gmail.com>
Project-URL: Homepage, https://github.com/variasov/classic-cache
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: classic-components~=1.3
Requires-Dist: orjson~=3.10
Requires-Dist: msgspec~=0.18
Provides-Extra: dev
Requires-Dist: build~=1.2.2.post1; extra == "dev"
Requires-Dist: pytest==8.3.4; extra == "dev"
Requires-Dist: pytest-cov==6.0.0; extra == "dev"
Requires-Dist: twine~=4.0; extra == "dev"
Requires-Dist: fakeredis==2.24.1; extra == "dev"
Requires-Dist: freezegun==1.5.1; extra == "dev"
Provides-Extra: redis
Requires-Dist: redis==5.0.8; extra == "redis"
Dynamic: license-file

# Classic Cache

Classic Cache - предоставляет функциональность кеширования.
Предоставляет утилиты для пометки кеша, бекенд для кеширования в RAM
и бекенд для кешироавния в Redis.

## Установка

Для установки Classic-Cache вы можете использовать pip:

```bash
pip install classic-cache
```

Для установки Classic-Cache с поддержкой Redis:

```bash
pip install classic-cache[redis]
```

## Использование

```python
from classic.cache import cached, InMemoryCache, RedisCache
from classic.components import component

@component
class SomeClass:

    # Кэширование результата метода some_method на 60 секунд
    @cached(ttl=60)
    def some_method(self, arg1: int, arg2: int) -> int:
        return arg1 + arg2

# кеширование в памяти
cache = InMemoryCache()
# ИЛИ
# кеширование в Redis
cache = RedisCache(connection=Redis())

some_instance = SomeClass(cache=cache)

# ручная инвалидация кэша
some_instance.some_method.invalidate(1, 2)
# ручное обновление кэша
some_instance.some_method.refresh(1, 2)
```
