npm.io
1.5.0 • Published yesterday

@nestjs-redisx/cache

Licence
MIT
Version
1.5.0
Deps
0
Size
1.0 MB
Vulns
0
Weekly
630

NestJS RedisX

@nestjs-redisx/cache

npm npm downloads license

Two-tier caching plugin for NestJS RedisX. L1 in-memory + L2 Redis with anti-stampede protection, stale-while-revalidate (SWR), tag-based invalidation, and declarative @Cached decorator.

Installation

npm install @nestjs-redisx/core @nestjs-redisx/cache ioredis

Quick Example

import { RedisModule } from '@nestjs-redisx/core';
import { CachePlugin, Cached } from '@nestjs-redisx/cache';

@Module({
  imports: [
    RedisModule.forRoot({
      clients: { host: 'localhost', port: 6379 },
      plugins: [new CachePlugin({ l1: { maxSize: 1000 }, l2: { defaultTtl: 3600 } })],
    }),
  ],
})
export class AppModule {}

@Injectable()
export class UserService {
  @Cached({ key: 'user:{0}', ttl: 300, tags: ['users'] })
  async getUser(id: string) {
    return this.repo.findById(id);
  }
}

Documentation

Full documentation: nestjs-redisx.dev/en/reference/cache/

Using with AI Assistants

For better code generation with AI tools (Cursor, Claude Code, GitHub Copilot, etc.), point your agent to the full API reference:

https://nestjs-redisx.dev/llms-full.txt

License

MIT

Keywords