Comments (7)
Closing as completed by #445
from io.
@IMax153 Why does the signature for getOption
include Error
? Since it will never hit the resolver function shouldn't it be Effect<never, never, Option.Option<Value>>
instead?
/**
* 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>>;
from io.
cc @tim-smart
from io.
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.
from io.
@tim-smart OK makes sense. Perhaps there's a need for another function then. A sort of getImmediateOption
that will run sync without any Error only returning the entry if it's actually already cached, ignoring any pending.
I think that may be the more useful behavior. The current getOption
is basically just a shorthand for the following.
pipe(
someCache.contains(key),
T.ifEffect(
pipe(cache.get(key), T.map(O.some)),
T.succeedNone()
)
AFAIK there's no way to do a getImmediateOption
with the current Cache api. I think it would be useful for situations where you want to take different actions based on whether a value is immediately available because a pending cache request could take an arbitrary amount of time to complete.
from io.
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>>
from io.
Closing as completed by #448
from io.
Related Issues (20)
- Configurable path delimiter in ConfigError HOT 1
- Feature Request - Add Pretty Print for `Exit` Data Type
- Feature request: tapErrorTag
- Feature request: throwTag, throwTagWith
- Feature request: Support using multiple Caches HOT 1
- Feature request: setConfigProviderEffect HOT 1
- Bug: Functions that work with tagged error fail at type level when non-tagged error present HOT 1
- From Discord: Missing Context Derivation in `effect-ts`: Renamed or No Longer Available? HOT 2
- Feature request: printing metrics
- Cache / Request Cache should allow specifying a weight function and a maximum weight
- Tiered caches
- Persisted caches
- Feature request: Multi-arg flatMap HOT 3
- From Discord: Difference in callback parameters for `filterOrFail` and `filterOrDie`
- From Discord: Proposing a `Effect.flatMapError` Function HOT 1
- From Discord: Missing Stack Trace in EffectA
- `Effect.serviceMembers` (and variants) do not recognize `Stream` returning members HOT 6
- From Discord: Converting Either to Effect in ZIO: ZIO.fromEither
- [Bug] Cause.reduceWithContext HOT 2
- From Discord: Lack of Concurrency/Batching Option for Effect.replicteEffect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from io.