-
-
Notifications
You must be signed in to change notification settings - Fork 17
Add getCached
function to Cache
module
#443
Comments
Closing as completed by #445 |
@IMax153 Why does the signature for /**
* Retrieves the value associated with the specified key if it exists.
* Otherwise returns `Option.none`.
*/
getOption(key: Key): Effect.Effect<never, Error, Option.Option<Value>>; |
cc @tim-smart |
The error is there because a cache entry can still be in a pending state, in the case where the lookup effect is async. If the cache entry is in a pending state, then it will await the underlying Deferred and pass any errors back to the caller. |
@tim-smart OK makes sense. Perhaps there's a need for another function then. A sort of I think that may be the more useful behavior. The current pipe(
someCache.contains(key),
T.ifEffect(
pipe(cache.get(key), T.map(O.some)),
T.succeedNone()
) AFAIK there's no way to do a |
Yes I don't see an issue with another API for getting a completed cache value. readonly getOptionComplete: (key: Key) => Effect<never, never, Option<Value>> |
Closing as completed by #448 |
@IMax153
It would be useful to have a utility function on Cache for "get cached value if it exists in the cache, otherwise none"
Pseudocode for workaround to do this:
The text was updated successfully, but these errors were encountered: