- Home
- Skills
- Andrueandersoncs
- Claude Skill Effect Ts
- Batching Caching
batching-caching_skill
- TypeScript
5
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill andrueandersoncs/claude-skill-effect-ts --skill batching-caching- SKILL.md7.9 KB
Overview
This skill explains how Effect optimizes API calls through batching, caching, and deduplication. It shows how to define request types and resolvers, enable automatic batching, and use built-in caching utilities like Effect.cached and the Cache service. The goal is to eliminate N+1 request patterns and reduce redundant network or database work.
How this skill works
Effect inspects request operations and can aggregate many individual requests into a single batched resolver call, allowing one network/database call to satisfy multiple logical requests. It also memoizes effect results and request outcomes within a query context, preventing duplicate concurrent work and enabling TTL-based or manual invalidation. You can opt in or out of batching and provide custom caches or resolvers with access to contextual services.
When to use it
- When facing N+1 query problems across loops or forEach operations
- When multiple callers request the same resource concurrently and you want deduplication
- When API or DB supports batch endpoints to reduce round trips
- When you need short-term memoization of expensive computations or network calls
- When you want fine-grained control over cache TTL, capacity, or invalidation
Best practices
- Use batched RequestResolvers at API boundaries to group related IDs into a single call
- Prefer Effect.cached or cachedWithTTL for inexpensive, read-heavy values to reduce repeated fetches
- Set TTLs to balance freshness and performance; use invalidate hooks for known changes
- Rely on automatic request deduplication within a query context to avoid duplicate inflight work
- Disable batching or request caching selectively for operations that must run independently
Example use cases
- Batching user lookups when iterating todos to avoid N+1 requests to /api/users
- Using RequestResolver.makeBatched to POST an array of ids and distribute results to individual requests
- Caching application config with Effect.cached so subsequent reads are instantaneous
- CachedWithTTL for current user data with automatic expiry after a short interval
- Creating a Cache service to control capacity, TTL, manual invalidation, and statistics
FAQ
Batched resolvers map results back to each original request, preserving per-request success or failure semantics. Ensure your batch endpoint returns results in a stable mapping or include identifiers in responses.
How do I force fresh data despite caching?
Use cachedInvalidateWithTTL to manually invalidate, or create/attach a custom cache and call invalidate. You can also disable request caching with Effect.withRequestCaching(false).