@dismissible/nestjs-memory-cache
v3.1.1
Published
In-memory LRU cache adapter for Dismissible
Maintainers
Readme
Dismissible manages the state of your UI elements across sessions, so your users see what matters, once! No more onboarding messages reappearing on every tab, no more notifications haunting users across devices. Dismissible syncs dismissal state everywhere, so every message is intentional, never repetitive.
@dismissible/nestjs-memory-cache
In-memory LRU cache adapter for the Dismissible system.
Overview
This library provides:
MemoryCacheAdapter- In-memory LRU cache implementation usinglru-cache- Cache adapter for the Dismissible system with automatic eviction
Installation
npm install @dismissible/nestjs-memory-cacheGetting Started
Using In-Memory Cache
The memory cache adapter is useful for development, testing, or single-instance production deployments:
import { Module } from '@nestjs/common';
import { DismissibleModule } from '@dismissible/nestjs-core';
import { MemoryCacheModule } from '@dismissible/nestjs-memory-cache';
@Module({
imports: [
DismissibleModule.forRoot({
cache: MemoryCacheModule.forRoot({
maxItems: 5000,
ttlMs: 6 * 60 * 60 * 1000, // 6 hours
}),
}),
],
})
export class AppModule {}Configuration Options
maxItems(optional): Maximum number of items to cache (default: 5000)ttlMs(optional): Time-to-live in milliseconds (default: 6 hours)
API Reference
MemoryCacheAdapter
An in-memory implementation of IDismissibleCache using LRU (Least Recently Used) eviction. Data is stored in memory and will be lost when the application restarts.
Note: This adapter is suitable for single-instance deployments. For distributed systems, consider using @dismissible/nestjs-redis-cache.
MemoryCacheModule
MemoryCacheModule.forRoot(options)
Register the memory cache adapter with configuration options.
MemoryCacheModule.forRootAsync(options)
Register the memory cache adapter with async configuration.
License
MIT
