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 redis_cache 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 redis_cache 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.0.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.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reche-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 45e9f01ead0bda11951294f609f8e1379568929bacb155e77fb0ee9cc9968de0
MD5 af01a607a02116e348c07bb93824fb7a
BLAKE2b-256 a5a7ec72c2692852142897eb07cdb829d1f2ab87b65fe53b04361b17e0cf666f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: reche-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3fccb2bd347b98e936cc0529c157a7cd739edf89815c00639bc2c196bea2e06d
MD5 b1edd1ac373d99ff10755f0494acaa15
BLAKE2b-256 6f2c11ce3ca412dce772a11f9d33851c629a3affc3efb6443c2b120cee5d06f3

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