Skip to content

Accept timedelta for ttl #334

Description

@allen0099

Problem

ttl must be an int number of seconds everywhere. @cache(ttl=timedelta(minutes=5)) raises CacheXError: ttl must be an int number of seconds, got timedelta, and the backends and CacheManager raise TypeError.

Proposal

Accept datetime.timedelta wherever a ttl (or stale_ttl) is taken, converting it to whole seconds, and reject values that are not whole seconds or that are out of range, as today. Keep bool/float rejected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendsCache backends and their atomic primitivescache-managerApplication-level CacheManagerdeveloper-experienceSurprising behaviour, missing warnings or unclear errors for library usersenhancementNew feature or requesthttp-cacheThe @cache decorator, cache keys and Cache-Control handling

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions