Skip to main content

A collection of helpful utilities for coredis.

Project description

PyPI Downloads Release

coredis-utils

A collection of helpful utilities for coredis.

Features

  • Caching decorator with thundering herd protection and error caching
  • Idempotency keys
  • Fixed-window rate limiting

Installation

$ pip install coredis-utils

Getting started

First, create a CoredisUtils object wrapping a coredis.Redis instance:

from coredis import Redis
from coredis_utils import CoredisUtils

client = Redis(...)
utils = CoredisUtils(client)

Caching is implemented with a decorator:

@utils.cached(ttl=60)
async def my_task() -> int: ...

Idempotency uses a simple check:

if await utils.idempotent("my-key", ttl=60):
    ...  # code in this block can only run once

Rate limiting is similar:

for _ in range(15):
    print(await utils.limit("my-ip-addr", 10, 1))  # limit to 10/second
True
True
True
True
True
True
True
True
True
True
False
False
False
False
False

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

coredis_utils-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

coredis_utils-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coredis_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for coredis_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 207337c99ebef56b2aadeed95e6d82ef5133b3fc402f5fed0d776fbc4d4a0546
MD5 ef99a0f27f8efc7dcf8b0770ccd11cdd
BLAKE2b-256 8af2770df71624f653f6d84c5a4898dba974246ac63ca885c08ca171d8d13a48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: coredis_utils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for coredis_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca6b6d511e52cf249122c803e9f2dc0d315e5a80ef2a34bcb8003bd973097d98
MD5 0f083b529fe6085183b5c7cf2b404e4c
BLAKE2b-256 05945b01b4f6671243d9dcf2af88acf36315ce54a14373fef1734c3402f65f1f

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