Skip to content

Redis clear_pattern does not prefix patterns that already start with the key prefix #109

Description

@allen0099

Problem

AsyncRedisCacheBackend.clear_pattern uses pattern if pattern.startswith(self.key_prefix) else self._make_key(pattern). The base contract says patterns match the logical key, and the Memory backend always prefixes.

Reproduced: with AsyncRedisCacheBackend(key_prefix="cache:") and the default CacheManager (whose own prefix is also cache:), clear_pattern("cache:user:*") is sent unprefixed and clears 0 keys, although cache:cache:user:1 exists.

Proposal

  • 0.3.8: always prefix. When that clears nothing and the pattern starts with the prefix, retry the legacy form and emit a DeprecationWarning.
  • 0.4.0: remove the fallback (tracked separately).

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 primitivesbugSomething isn't working

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions