INNER CODE UNIT · Python

_is_stale_for_client

redis/fastapi-redis-sdk · src/redis_fastapi/cache.py:139

def _is_stale_for_client(
    remaining_ttl: int, ttl: int, cc: dict[str, str | bool]
) -> bool:
    """Return ``True`` when the cached entry is too old for the client's max-age.

    ``remaining_ttl`` is the Redis TTL remaining; ``ttl`` is the original TTL
    used when the entry was stored.  The entry's age is ``ttl - remaining_ttl``.

    Args:
        remaining_ttl: Seconds left on the Redis key.
        ttl: Original TTL the entry was stored with.
        cc: Parsed ``Cache-Control`` directives from the request.

    Returns:
        ``True`` if the entry's age meets or exceeds the client's ``max-age``.
    """
    client_max_age = cc.get("max-age")
    if client_max_age is None:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…