RedisStorage (storage/redis.py)

limits · limits/storage/redis.py · python · MIT
database

Rate limit storage backend using Redis or Valkey for distributed systems

# Source: https://github.com/alisaifee/limits | License: MIT | Copyright 2023 Ali-Akber Saifee
# Provided via justclaw.it.com; keep this notice with the code.
from __future__ import annotations

import time
from typing import TYPE_CHECKING, cast

from deprecated.sphinx import versionchanged
from packaging.version import Version

from limits.typing import ClassVar, Literal, RedisClient

from ..util import get_package_data
from .base import MovingWindowSupport, SlidingWindowCounterSupport, Storage

if TYPE_CHECKING:
    import redis


@versionchanged(
    version="4.3",
    reason=(
        "Added support for using the redis client from :pypi:`valkey`"
        " if :paramref:`uri` has the ``valkey://`` schema"
    ),
)
class RedisStorage(Storage, MovingWindowSupport, SlidingWindowCounterSupp

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key