Caching a Function Call with Effect.cached

Is this a correct way to cache a function call?

const getModel = Effect.sync(() => {
  return USE.load();
}).pipe(Effect.cached); // expensive process

export const handler: Handler = (event: { query: string }, _: Context) =>
  Effect.gen(function* () {
    const cached = yield* getModel;
    return yield* cached.pipe(Effect.map((model) => model.embed(event.query)));
  }).pipe(Effect.runPromise);
Was this page helpful?