Skip to content

feat: adding a way to use different values for max capacity query - #506

Open
maugustosemperfi wants to merge 2 commits into
Baseflow:mainfrom
maugustosemperfi:objects-over-capacity-duration-parameter
Open

maugustosemperfi wants to merge 2 commits into
Baseflow:mainfrom
maugustosemperfi:objects-over-capacity-duration-parameter

Conversation

@maugustosemperfi

@maugustosemperfi maugustosemperfi commented Jan 22, 2026 •

Copy link
Copy Markdown

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Feature - Adds a new configurable maxCapacityAgeFilterDuration parameter to customize the age threshold for cache object cleanup.

⤵️ What is the current behavior?

When cleaning up cache objects over capacity, the getObjectsOverCapacity method uses a hardcoded Duration(days: 1) filter. This means only objects that haven't been touched in the last 24 hours are considered for removal, with no way to customize this behavior.

🆕 What is the new behavior (if this is a feature change)?

  • Added maxCapacityAgeFilterDuration optional parameter to Config
  • The getObjectsOverCapacity method now accepts a maxAge parameter
  • CacheStore uses the configured duration (falling back to 1 day if not set)
  • All repository implementations (CacheObjectProvider, JsonCacheInfoRepository, NonStoringObjectProvider) updated to support the new parameter

This allows users to configure how recently an object must have been accessed before it becomes a candidate for removal during over-capacity cleanup.

💥 Does this PR introduce a breaking change?

No - The parameter is optional with a default value matching the previous hardcoded behavior (Duration(days: 1)).

🐛 Recommendations for testing

  1. Create a cache manager with custom maxCapacityAgeFilterDuration (e.g., Duration(seconds: 10))
  2. Add objects exceeding capacity
  3. Verify only objects older than the configured duration are cleaned up
  4. Verify default behavior (no parameter) still uses 1 day threshold

📝 Links to relevant issues/docs

N/A

🤔 Checklist before submitting

  • All projects build
  • Follows style guide lines (code style guide)
  • Relevant documentation was updated
  • Rebased onto current develop

@Syed-Bipul-Rahman Syed-Bipul-Rahman left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the feature for max capacity query

@rickdijk
rickdijk changed the base branch from develop to main September 16, 2026 00:18
cache_object_provider.dart conflicted only with main's format pass
(cce9a65). Took main's formatting and re-applied this branch's change,
and formatted this branch's other hunks. test/mock.mocks.dart
regenerated with build_runner.

Co-Authored-By: Claude <noreply@anthropic.com>
@rickdijk

Copy link
Copy Markdown
Contributor

main has moved since you opened this, and our changes to cache_object_provider.dart and test/mock.mocks.dart left it conflicting. I have merged main into your branch, resolved those conflicts and regenerated mock.mocks.dart with build_runner. Your change itself is untouched, apart from dart format reflowing your new lines to match the formatting pass on main. Once CI runs, flutter analyze will report that Config in lib/src/config/_config_io.dart and lib/src/config/_config_web.dart does not implement the new maxCapacityAgeFilterDuration getter. That was already the case before the merge, and adding it to both is what is left.

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.

3 participants