CacheStore
Response caching with TTL. Memory uses LRU eviction; SQLite and DynamoDB use entry size limits.
HTTP Client Toolkit ships three store backends. Each implements the same interfaces (CacheStore, DedupeStore, RateLimitStore, AdaptiveRateLimitStore), so you can swap between them without changing application code.
| Memory | SQLite | DynamoDB | |
|---|---|---|---|
| Persistence | Process lifetime | Disk | Cloud |
| Multi-instance | No | Shared file | Yes |
| Dependencies | None | better-sqlite3, drizzle-orm | AWS SDK v3 (peer) |
| Cleanup | Background timers | Background timers | Native TTL |
| Best for | Dev, testing, single-process | Persistent local, process restarts | Serverless, distributed |
Each backend provides four store implementations:
CacheStore
Response caching with TTL. Memory uses LRU eviction; SQLite and DynamoDB use entry size limits.
DedupeStore
Request deduplication with atomic ownership. One caller fetches, others wait for the result.
RateLimitStore
Sliding window rate limiter with per-resource configuration.
AdaptiveRateLimitStore
Priority-aware rate limiter that dynamically allocates capacity between user and background requests.
import { HttpClient } from '@http-client-toolkit/core';import { InMemoryCacheStore, InMemoryDedupeStore, InMemoryRateLimitStore,} from '@http-client-toolkit/store-memory';
const client = new HttpClient({ cache: new InMemoryCacheStore(), dedupe: new InMemoryDedupeStore(), rateLimit: new InMemoryRateLimitStore(),});import { HttpClient } from '@http-client-toolkit/core';import Database from 'better-sqlite3';import { SQLiteCacheStore, SQLiteDedupeStore, SQLiteRateLimitStore,} from '@http-client-toolkit/store-sqlite';
const db = new Database('./app.db');
const client = new HttpClient({ cache: new SQLiteCacheStore({ database: db }), dedupe: new SQLiteDedupeStore({ database: db }), rateLimit: new SQLiteRateLimitStore({ database: db }),});import { HttpClient } from '@http-client-toolkit/core';import { DynamoDBClient } from '@aws-sdk/client-dynamodb';import { DynamoDBCacheStore, DynamoDBDedupeStore, DynamoDBRateLimitStore,} from '@http-client-toolkit/store-dynamodb';
const dynamoClient = new DynamoDBClient({ region: 'us-east-1' });
const client = new HttpClient({ cache: new DynamoDBCacheStore({ client: dynamoClient }), dedupe: new DynamoDBDedupeStore({ client: dynamoClient }), rateLimit: new DynamoDBRateLimitStore({ client: dynamoClient }),});You can also mix backends — for example, use in-memory cache for speed with a DynamoDB rate limiter for distributed coordination:
const client = new HttpClient({ cache: new InMemoryCacheStore(), // Fast local cache rateLimit: new DynamoDBRateLimitStore({ ... }), // Shared rate limit});