Skip to content

feat: configurable auto-eviction#508

Merged
vladar merged 2 commits intomainfrom
vladar/fr-optional-gc
Jan 31, 2025
Merged

feat: configurable auto-eviction#508
vladar merged 2 commits intomainfrom
vladar/fr-optional-gc

Conversation

@vladar
Copy link
Copy Markdown
Contributor

@vladar vladar commented Jan 31, 2025

Today ForestRun does automatic data eviction when the number of operation exceeds maxOperationResult option. This PR introduces an autoEvict option which allows disabling automated eviction and instead control when data eviction kicks in with gc method from Apollo cache interface.

Related options:

  • autoEvict: default true
  • maxOperationCount: default 1000

},
mergePolicies: new Map(),
readPolicies: new Map(),
autoEvict: config?.autoEvict ?? true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: Would be nice to have it sorted alphabetically someday

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe someday :) I prefer having related options grouped together - so if we sort alphabetically we will need to rename them to have a common prefix for the same "group" (or introduce another level of objects for grouping). Which is a breaking change.

const cache = new ForestRun({
maxOperationCount: 1,
autoEvict: false,
nonEvictableQueries: new Set(["b"]), // root-level field
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: maxOperationCount is actually increased by length of nonEvictableQueries, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, by design

@vladar vladar merged commit bedc553 into main Jan 31, 2025
2 checks passed
@vladar vladar deleted the vladar/fr-optional-gc branch January 31, 2025 08:50
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.

2 participants