effect-cache

Implements in-memory caching of effectful lookups with Effect v4 Cache and ScopedCache.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-cache-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-cache
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-cache
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-cache-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect.

What problem does it solve? Caching results of effectful operations (API calls, database reads, connection acquisition) in Effect TypeScript applications requires handling TTL expiry, LRU eviction, concurrent request deduplication, failure caching, and resource lifecycle — all of which are easy to get wrong with ad-hoc memoization. ## Core Features & Use Cases - Keyed caching with Cache: Memoize effectful lookups by key with capacity limits, LRU eviction, fixed or exit-aware TTL, and automatic deduplication of concurrent lookups for the same key. - Resource-owning entries with ScopedCache: Cache values that own resources (connections, file handles) with per-entry scopes so finalizers run exactly on eviction, expiry, invalidation, or cache close. - Refresh and invalidation control: Use stale-while-revalidate refresh, write-through set, and conditional invalidation to keep cached data fresh. - Use Case: Build a cached user repository service via Layer where lookups hit a database, successes cache for 5 minutes, failures cache for zero seconds, and write-through updates keep the cache consistent. ## Quick Start Ask the assistant to add TTL-based caching with concurrent deduplication to an Effect lookup function using Cache.makeWith.

Frequently Asked Questions about effect-cache

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I cache effectful lookups by key in Effect TypeScript?

Use Cache.make with a lookup function, capacity, and optional timeToLive, then call Cache.get(cache, key). Concurrent gets of the same missing key share one lookup, and both successes and failures are cached until expiry or invalidation.

What is the difference between Cache and ScopedCache in Effect v4?

Cache stores plain values, while ScopedCache gives each entry its own Scope so resources acquired during the lookup are released when the entry is evicted, expires, is invalidated, or the cache closes. Use ScopedCache for connections or file handles.

Why does a failed lookup keep failing from the Effect cache?

Cache stores the lookup Exit, so failures are replayed with the default infinite TTL. Use Cache.makeWith with an exit-aware TTL such as Exit.isSuccess(exit) ? '5 minutes' : Duration.zero to avoid caching failures or interrupts.

Does Effect Cache support TTL testing with TestClock?

Yes, TTL is computed against the fiber's Clock, so TestClock.adjust advances expiry deterministically in tests. Expiry is lazy: entries are removed when next touched by get, has, keys, values, or entries.

When should I use Pool instead of ScopedCache in Effect?

Use effect/Pool when you need a fixed set of interchangeable resources checked out per use. ScopedCache is for keyed caching where each entry owns its resource and dies with the entry; values must not be held beyond the entry's lifetime.