@forgeframework/cache
v0.3.0
Published
Provides a unified caching layer for the Forge Framework.
Maintainers
Readme
@forgeframework/cache
Provides a unified caching layer for the Forge Framework.
Part of the Forge Framework — a TypeScript framework for backend microservices and web applications.
Installation
npm install @forgeframework/cacheUsage
import { CacheManager } from '@forgeframework/cache';
const cache = new CacheManager({
defaultStore: 'memory',
defaultTtl: 300,
stores: {
memory: { type: 'memory', maxSize: 5000, evictionPolicy: 'lru' },
redis: { type: 'redis', url: 'redis://localhost:6379' },
},
});
// Basic operations
await cache.set('user:123', userData, 600);
const user = await cache.get<User>('user:123');
// Wrap pattern (cache-aside)
const user = await cache.wrap('user:123', () => userRepo.findById('123'), 600);
// Use specific store
const redisStore = cache.store('redis');
await redisStore.set('session:abc', sessionData, 3600);
// Batch operations
const users = await cache.getMany<User>(['user:1', 'user:2', 'user:3']);Documentation
Full API reference and guides: https://carbonforge.io/framework/docs/db/cache
(Documentation site launching soon.)
License
MIT © Carbon Forge
