Skip to main content

Reche (Redis Cache) is a Python library that provides a simple interface for caching data in Redis.

Project description

Reche (Redis Cache)

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

Установка

  • 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

Использование (sync)

import time
import redis
from reche import RedisCache


redis_client = redis.Redis(host="localhost", port=6379, db=0)
rcache = RedisCache(redis_client)

@rcache.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)
rcache = RedisCache(redis_client)

@rcache.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


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.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

reche-0.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file reche-0.1.1.tar.gz.

File metadata

  • Download URL: reche-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for reche-0.1.1.tar.gz
Algorithm Hash digest
SHA256 37d5a4cfd4ba3f99097449b760ef17fb9f704e3a5eeca0d1bdb094435eeded38
MD5 49c4b646674fe1dc0cabe182e8a2799d
BLAKE2b-256 ddd7c71149990cdc7a391c08bdf698f7ce8ecb45d14fd978e44bdea34e5bb16d

See more details on using hashes here.

File details

Details for the file reche-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: reche-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for reche-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 14ec0e45532b4e1a59be7eb064645fa5f695e0526f88e0c342a102aae4dceb28
MD5 8b1a1e2c64310e693503ce80871ec3c5
BLAKE2b-256 11a9039bd4502b5764321e978859f1102a0cae3987521e55bd0cc1e89526250d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page