Effect CommunityEC
Effect Communityβ€’3y agoβ€’
11 replies
Patrick Roza

Comparing Global Cache with Tag and Layer for Testing

if I need a global cache, and I don't have a reason right now to replace it with a different service for testing,
would there be any reason to create a tag and layer (and provide it), if I can instead just do this?
export const Eod = Cache
   .make<
     EodRequest,
     EodRepo | HttpClient.Default,
     InvalidStateError | OptimisticConcurrencyException,
     readonly EODData[]
   >({
     capacity: 100,
     timeToLive: Duration.hours(2),
     lookup
   })
   .cached
   .runSync

my thinking is: build the simplest thing possible first, and later "upgrade" it to tag+layer when I need to.
as both Effect and Tag are treated equally to consume, there isn't much difference, outside hiding dependencies from caller.
The tag/layer approach would be global/singleton too for all intents and purposes from the program's perspective.
Was this page helpful?