Skip to content

Add faster namespace or tag-based invalidation #163

Description

@jaysin586

Summary

Explore an optional indexed invalidation path, such as tags or namespaces, so callers can delete related entries without scanning the full cache.

Why

deleteByPrefix() and deleteByMagicString() scan all keys. That is simple and useful, but prefix/wildcard deletion is a promoted capability, so larger caches may need a faster invalidation model.

Current references

  • src/cache.ts: deleteByPrefix()
  • src/cache.ts: deleteByMagicString()

Review questions

  • Is tag-based invalidation worth the additional internal index maintenance?
  • Should tags be supplied via set(key, value, { tags }) and getOrSet(key, fetcher, { tags })?
  • Can we keep existing wildcard APIs scan-based and add tags as an opt-in fast path?

Acceptance criteria

  • Proposed API keeps zero dependencies and preserves existing deletion methods.
  • Indexed invalidation removes only matching entries and cleans associated metadata.
  • Tests cover delete by tag/namespace, overwrites, deletes, clear, and TTL expiration cleanup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions