Introduce custom cache client support. #93
Merged
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.
Description
Introduces support for consumers of
work
to provide their own cache clients in the event they wish not to use the default in-memory caching. For example, users may provide clients for Redis or Memcache instead if they desire some distributed caching options.Rationale
Depending on the use cases consumers of this library may be dealing with very large sets of data and performing large scale modifications over that data. Using an in-memory caching solution only is applicable in scenarios where the limits of how many entities to be cached is well defined and is small enough to not overwhelm the system. In all other scenarios, distributed caching is a much safer alternative.
Callouts
In order to achieve this,
context.Context
had to be introduced on all unit operations. This is because all of the operations would result in issuing remote calls to the cache (using the provided clients), as all operations besidesRegister
result in deleting the corresponding entity from the cache (since it would then be classified as "dirty").Planned Follow Ups
UnitCacheClient
.Suggested Version
v4.0.0-beta.6
Example Usage