Effect CommunityEC
Effect Communityβ€’5w agoβ€’
17 replies
Frederic

Handling Composite Keys in Cache.Make with Lookup Function

Hi, How can I possibly handle composite keys in the context of the lookup function of Cache.Make:
The following does not work - two identical keys will be considered different and added to the cache.:
      const ProductKey = Data.struct<{ kind: "product"; id: string }>({ kind: "product", id: "" })
      const cache = yield* Cache.make({
        capacity: 100,
        timeToLive: Duration.days(10),
        lookup: (key: typeof ProductKey) => getProduct(key.id),
      })
Was this page helpful?