Conversation
Simplify rebasing by calling `this.cache.reset(base.cache)` Instead of resetting the cache state by updating the cache with inverse operations.
…`, `transformsSince` in favor of `getTransformsSince` Provide naming consistency with other `getX` methods.
Allow caches to track ops that are applied via `update`. This will be done by default when a `base` cache is set. Otherwise, the `trackUpdateOperations: true` configuration setting is required to enable this feature.
…tracked
If a cache is tracking update operations, which is now the default for forked caches, then when the associated source is merged, the cache's operations will be applied in a single transform.
The benefit here is that it allows caches to be manipulated synchronously, and to have all those updates applied during a merge.
If you want to continue to merge only transforms applied to a source, and not its cache, then create the fork with `source.fork({ cacheSettings: { trackUpdateOperations: false } });`.
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.
The primary use case of
MemorySourceforking is to create an isolated source and cache, which can be modified and then merged back into its base, with all the associated operations coalesced.Because the forked
MemorySourceis "just" anotherSource, updates to it are still async, which allows for those updates to be logged, interacted with through other sources, etc. through async processes. Until now, there has been no way to synchronously make changes to a fork and then merge those back to the base source, because only updates at the source level have been tracked.Optional update tracking in
MemoryCacheThis PR introduces a new optional form of update tracking in the
cacheassociated with a source. By default now, this capability will be enabled in forked caches. Any updates applied to the cache will be tracked and used to form the merge transform whenmergeis invoked. This means that synchronous changes could be made to a forked cache directly rather than going through the associated source. Changes could also still be applied via updates to the forked source, since those will internally also invokeupdateon the cache and be tracked.If you want to continue to track changes only at the source-level and have
mergework only with those changes, pass the following config when you fork a source:This will prevent update tracking at the cache level and will signal to
mergethat only transforms applied at the source-level should be merged.Other new
MemoryCachecapabilitiesAlong with change tracking at the cache-level, this PR also introduces the following methods to
MemoryCache:fork- creates a new cache based on this one.merge- merges changes from a forked cache back into this cache.rebase- resets this cache's state to that of itsbaseand then replays any update operations.MemoryCacheforking / merging / rebasing is a lighter-weight way of "branching" changes, that can ultimately be merged back into a source. Cache-level forking can be paired with source-level forking for a lot of flexibility and power.