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

Metadata

Release files for simple-redis-cache 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-redis-cache 1.4.0
File Size Uploaded Provenance Actions
simple_redis_cache-1.4.0.tar.gz 10.4 kB Without provenance Details for simple_redis_cache-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simple-redis-cache 1.4.0
File Interpreter ABI Platform Actions
simple_redis_cache-1.4.0-py3-none-any.whl Python 3 none any Details for simple_redis_cache-1.4.0-py3-none-any.whl

Total release size: 24.8 kB

Release files / simple_redis_cache-1.4.0.tar.gz

Download URL simple_redis_cache-1.4.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
25c0878193111b1a8cada8b166c48515bf6b96d427533ce51c294ca44d3ee5c4
BLAKE2b-256 checksum
How to use checksums
c0c8d7307c7c6ec158e660016457b864f46a33ba9b8d5aaf750fb36e72ba11c1
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / simple_redis_cache-1.4.0-py3-none-any.whl

Download URL simple_redis_cache-1.4.0-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1edd6f4622ac860e3d902ba9c72df293e2e96a3ba0cbad35c98df6f87f074dca
BLAKE2b-256 checksum
How to use checksums
4ee564e90282282aece196ead753a32e7de8644bba9e4c3a9ba40a8927779607
Upload date
Uploaded using Trusted Publishing?
What is 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}

Security for simple-redis-cache 1.4.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.

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