Effect CommunityEC
Effect Community2w ago
2 replies
Jules

Approach to Caching and Web Frameworks with Effect Typescript

Hey!
What would be a good approach to caching and web frameworks?

AFAIK, when you try to use Effect inside a framework, you will have to end up using some Effect.runPromise somewhere to get the values out of Effect. By doing it that, it means that all the caching benefits of Effect.cached or Effect.cachedFunction will be scoped to the runPromise, and the computation will be triggered every run.
Of course, you can do a Effect.runSync(Effect.cached(…)) to create a globally cached function, but the problem with this approach is that it basically makes the code hard to test, especially when the cached effect is inside a service. Thus the question
Was this page helpful?