Skip to main content

simple-redis-cache

PyPI Redis uv Pytest

Простой инструмент для кэширования асинхронных и синхронных функций в Redis.

  1. Документация
  2. Ссылка на PyPI

Особенности

  • Автоматическая генерация ключей — ключи создаются на основе имени функции и аргументов
  • Инвалидация по префиксу — очищайте кэш группами
  • Кастомный JSON-энкодер — поддерживает datetime, Decimal, UUID, Pydantic-модели
  • Устойчивость к ошибкам — ошибки Redis не ломают приложение
  • Гибкая настройка — можно передать свой логгер
  • sync/async поддержка — можно использовать как для синхронных, так и для асинхронных функций
  • 100% покрытие - полная уверенность в коде
  • 100% docstrings - полная документация функций

Установка

pip install simple-redis-cache

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

from simple_redis_cache.sync import Cache  # Синхронный
from simple_redis_cache.asyncio import Cache  # Асинхронный

Пример

from redis.asyncio import Redis
from simple_redis_cache import Cache

redis = Redis()
cache = Cache(redis)


@cache.cache(ttl=60, prefix="user")
async def get_user(user_id: int):
    return {"id": user_id, "name": "Alice"}


# Первый вызов — вычисляется, второй — из кэша
r1 = await get_user(1)
r2 = await get_user(1)

# Одинаковый результат
print(r1 == r2)

Инвалидация

await cache.invalidate_cache(prefix="user")

Лицензия

MIT

Автор

hotpotato89

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_redis_cache-1.2.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_redis_cache-1.2.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file simple_redis_cache-1.2.0.tar.gz.

File metadata

  • Download URL: simple_redis_cache-1.2.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for simple_redis_cache-1.2.0.tar.gz
Algorithm Hash digest
SHA256 155e76e763968bb8be04509c8cfd2d449f54daead6da9f7e786fef646ee4835a
MD5 85c6d0492367a148f3abd775bbb03113
BLAKE2b-256 ca5f6a6c07fbbcb60f764792cb50d9b0786fe18fc9ee5a6e1c4386818ec035ff

See more details on using hashes here.

File details

Details for the file simple_redis_cache-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: simple_redis_cache-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for simple_redis_cache-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c3f38bd1cf7479875494b3648b5e97602036a9f6916e70c97e6721b3e9c9aa1
MD5 16b54e5be67ad65dfd1da41b0b7117ba
BLAKE2b-256 79908ec90b846ce9174b9956aff687e170bb4473a0198d42c4bcffae3b92d285

See more details on using hashes here.

Release history Release notifications | RSS feed

1.4.0

2 files

1.3.0

2 files

This release

1.2.0 This release

2 files

1.1.0

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page