Memory-bounded server scope management for StateLoom. Prevents memory leaks from per-request scopes with LRU eviction and TTL-based expiration.
pnpm add @stateloom/serverimport { createServerScope } from '@stateloom/server';
const scopes = createServerScope({
maxEntries: 10_000,
ttl: 30 * 60 * 1000, // 30 minutes
onEvict: (id, scope) => scope.dispose(),
});
// Per-request handler
function handleRequest(sessionId: string) {
const scope = scopes.get(sessionId);
// Use scope for isolated state...
}| Export | Description |
|---|---|
createServerScope(options) |
Create a server scope manager with LRU + TTL eviction |
Full documentation with API reference, lifecycle management, and framework integration: docs/api/server
MIT