-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to add cache entries directly, bypassing the Lookup
function
#39
Comments
This is important and what currently make us unable to use |
This is also in our way to start using zio-cache. |
Hey all, I would find this useful as well as another use case to motivate this is the bulk addition of values into the cache. |
Yes I think supporting looking up a collection of values would be a better way to support this. I have an outstanding PR to add this that I will update. |
@adamgfraser I think you're referring to this PR #143. Do you have an ETA on when that will be added in/if there are still plans to support multi-lookup? |
I would really like to have this too. This is a very basic requirement for every cache imho. |
I digged into this and it I think this won't be possible with the current design. The It would probably be better to have another version of the cache that is invariant, which would allow to add a Thoughts from the maintainers? I would start working on a PR if the design goal is clear. |
Motivation
In some scenarios, we might want to add a value to the cache directly without calling the lookup function. An example of such business logic is we have some special values that don't exist in the database (from which the lookup function retrieves values), nonetheless we want to serve these special values by injecting them directly into the cache.
Considerations
The decision to bypass lookup is most likely determined by some external conditions. Currently the
Lookup
function has the following signature:And this function is provided upfront during the construction of the cache, when the conditions to bypass might not be available.
We'd probably either need to express the conditions and the value to add through
Environment
, or need to add additional (optional) parameters to thelookup
function.The text was updated successfully, but these errors were encountered: