Skip to content

0.4.0: make BaseCacheBackend.delete() return whether a key was removed #71

Description

@allen0099

BaseCacheBackend.delete() returns None for 0.3.x compatibility. Atomic one-shot removal is already available through get_and_delete(), but a plain "did anything get deleted?" answer is the better signature and is what callers expect from the underlying stores (Redis DEL returns a count, Memcached delete(noreply=False) returns a bool).

To do

  • Change the abstract signature to async def delete(self, key: str) -> bool.
  • Implement it in Memory, Redis and Memcached.
  • Update delete_many's base fallback, which currently counts attempted deletes because delete cannot say whether the key existed.
  • Third-party backends that return None break under type checking; call that out in the changelog.

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 primitivesbreaking-changeChanges public behaviour or API; needs a minor/major release

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions