Skip to content

Move cache policy to instance and rename cacheable() to remember()#11

Merged
grischaerbe merged 2 commits into
nextfrom
grischaerbe/policy-on-instance
Apr 28, 2026
Merged

Move cache policy to instance and rename cacheable() to remember()#11
grischaerbe merged 2 commits into
nextfrom
grischaerbe/policy-on-instance

Conversation

@grischaerbe
Copy link
Copy Markdown
Owner

Summary

  • Move cache policy configuration from per-entry to per-instance (set on new Cacheables({ policy, maxAge }))
  • Rename cache.cacheable() to cache.remember() for clearer semantics
  • Bump major version to 3.0.0 (breaking API changes)

Test plan

  • tests/index.test.ts updated and passing
  • tests/fetchPolicies.test.ts updated and passing

🤖 Generated with Claude Code

grischaerbe and others added 2 commits April 28, 2026 11:44
Policy and maxAge are now configured once on the Cacheables constructor
and apply to every entry in that instance, replacing the per-call options
arg on cacheable(). This eliminates cross-policy cache entries and the
errors that came with them. To compose policies, create multiple instances.

The constructor key was renamed cachePolicy -> policy (the class name
already implies "cache") and the CacheableOptions export was removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@grischaerbe grischaerbe changed the base branch from master to next April 28, 2026 09:59
@grischaerbe grischaerbe merged commit ba0a692 into next Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant