Effect CommunityEC
Effect Community•2y ago•
88 replies
attila

Title: Implementing Batching and Caching with Request Primitive

Hi there šŸ‘‹
I'm following the docs on batching and caching to learn more about the Request primitive. I've implemented the getTodos, getUserByIds, and sendEmails so that they read from/write to a file (pretending to be the database) instead of a network call with some extra logging.

The output I see is this:
Fetching todos...
Fetching users 1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5...
Fetching users 1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5...
Sending 50 emails


Is it expected that requests are not de-duplicated by default? (My todos db contains 50 records, the todo ownership is evenly distributed across 5 unique users)
Is deduplication of requests possible?
Effect is a powerful TypeScript library designed to help developers easily create complex, synchronous, and asynchronous programs.
Batching & Caching – Effect Docs
Was this page helpful?