NestJS Profiler
API Reference

nest-profiler-cache

Types and API of the cache collector.

CacheOperationEntry

One entry per cache operation (get, set, del) executed during a request.

Prop

Type

CacheOperation

type CacheOperation = 'GET_HIT' | 'GET_MISS' | 'SET' | 'DEL';
  • GET_HIT - cache get() returned a value
  • GET_MISS - cache get() returned undefined or null
  • SET - cache set() was called
  • DEL - cache del() was called

Public exports

import { CacheCollectorModule } from '@eleven-labs/nest-profiler-cache';
import { CacheCollector } from '@eleven-labs/nest-profiler-cache';

import type { CacheOperationEntry, CacheOperation } from '@eleven-labs/nest-profiler-cache';

Setup

// In the module that uses CACHE_MANAGER:
import { ConditionalModule } from '@nestjs/config';
import { CacheCollectorModule } from '@eleven-labs/nest-profiler-cache';

const isProfilerEnabled = (env: NodeJS.ProcessEnv) => env['PROFILER_ENABLED'] === 'true';

@Module({
  imports: [ConditionalModule.registerWhen(CacheCollectorModule.forRoot(), isProfilerEnabled)],
})
export class PostsModule {}

CacheCollectorModule.forRoot() takes no configuration options. The collector patches the CACHE_MANAGER's get, set, and del methods with a proxy at module initialization.

There is no forRootAsync by design: the collector has no runtime-resolved options (its only knob, enabled, is a synchronous build-time decision), so toggle it per environment with ConditionalModule.registerWhen(...).

Prerequisite: CacheModule.register({ isGlobal: true }) from @nestjs/cache-manager must be registered in the application (provides CACHE_MANAGER globally).

Powered & maintained by

On this page