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 {
  CacheCollectorModuleOptions,
  CacheOperationEntry,
  CacheOperation,
} from '@eleven-labs/nest-profiler-cache';

Setup

profiling/profiling.module.ts
import { Module } from '@nestjs/common';
import { ProfilerModule } from '@eleven-labs/nest-profiler';
import { CacheCollectorModule } from '@eleven-labs/nest-profiler-cache';

@Module({
  imports: [ProfilerModule.forRoot({ isGlobal: true }), CacheCollectorModule.forRoot()],
})
export class ProfilingModule {}

ProfilingModule is the dev-only bundle loaded by main-dev.ts — see Enabling and disabling the profiler. If the profiler is installed as a production dependency behind the runtime gate, wrap the same call in ConditionalModule.registerWhen(..., isProfilerEnabled).

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). It lives in the dev-only bundle, or is gated with ConditionalModule.registerWhen(...) under the runtime gate.

Prerequisite: CacheModule.register({ isGlobal: true }) from @nestjs/cache-manager must be registered in the application (provides CACHE_MANAGER globally, so the collector can inject it from the bundle).

Powered & maintained by

On this page