feat: add limit option to useResponseCaching for entry eviction - #737
Merged
Conversation
Add limit configuration to ResponseCachingConfiguration that supports maxEntries and maxBytes constraints per endpoint group. When limits are exceeded, oldest cache entries are evicted first. Group metadata is stored alongside cache entries in the same Storage using a 'coalesce:group:' key prefix. The default group key is the endpoint URL path without query parameters, and can be customized via limit.key. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Allow limit.key to be a function (req, defaultKey) => string in addition to a static string, for dynamic group key computation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an optional limit configuration to useResponseCaching() in coalesce-vue to cap cached responses per endpoint group (by entry count and/or total serialized size), evicting oldest entries first. This extends the existing client-side response cache behavior and documents the new configuration for framework consumers.
Changes:
- Extended
ResponseCachingConfigurationwith alimitoption and implemented group metadata + eviction viaenforceGroupLimits(). - Added test coverage for
maxEntries,maxBytes, custom group keys, function-based keys, and stale-reference cleanup. - Updated Vue API client docs and added a changelog entry describing the new option.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/coalesce-vue/src/api-client.ts | Adds limit configuration, persists group metadata in Storage, and enforces per-group eviction on cache writes. |
| src/coalesce-vue/test/api-client.spec.ts | Adds tests covering eviction behavior and group metadata handling. |
| docs/stacks/vue/layers/api-clients.md | Documents the new limit option and provides an example. |
| CHANGELOG.md | Notes the new limit option for useResponseCaching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
limitoption touseResponseCaching()that constrains how many cached responses are stored per endpoint group. When limits are exceeded, the oldest entries are evicted first.Configuration
Implementation
Storagealongside cache entries, using acoalesce:group:key prefixpurgeStaleCacheEntriesor other means) are cleaned up from group metadatamaxBytesChanges
src/coalesce-vue/src/api-client.ts- AddedlimittoResponseCachingConfigurationtype, addedenforceGroupLimits()helper, updated cache write pathsrc/coalesce-vue/test/api-client.spec.ts- Tests for maxEntries, maxBytes, custom group keys, and stale reference cleanupdocs/stacks/vue/layers/api-clients.md- Updated documentation with limit option details and exampleCHANGELOG.md- Added changelog entry