nest-profiler-cache
Record cache GET/SET/DEL operations and the hit ratio in the Cache panel.
@eleven-labs/nest-profiler-cache
@eleven-labs/nest-profiler-cache intercepts @nestjs/cache-manager operations (GET HIT, GET MISS, SET, DEL) during a profiled execution and displays them in a Cache panel with hit/miss statistics.

Installation
pnpm add @eleven-labs/nest-profiler-cache@alpha @nestjs/cache-managerThere is no stable release yet — install every
@eleven-labs/nest-profiler*package with the@alphadist-tag (@latestresolves to nothing).
Peer dependencies: @nestjs/cache-manager ^3.0.0
Setup
import { ConditionalModule } from '@nestjs/config';
import { CacheModule } from '@nestjs/cache-manager';
import { CacheCollectorModule } from '@eleven-labs/nest-profiler-cache';
const isProfilerEnabled = (env: NodeJS.ProcessEnv) => env['PROFILER_ENABLED'] === 'true';
@Module({
imports: [
CacheModule.register({ isGlobal: true }),
ConditionalModule.registerWhen(CacheCollectorModule.forRoot(), isProfilerEnabled),
],
})
export class AppModule {}Enabling / disabling — gate the collector with
ConditionalModule.registerWhen(..., isProfilerEnabled)as shown, so it loads only whenPROFILER_ENABLEDis on. Wire the coreProfilerModuleonce at the root — the recommended setup bundles the root-level profiler modules into a singleProfilingModulebehind aConditionalModulegate (see Enabling and disabling the profiler and the example app). A top-levelenabledoption is also supported as an alternative.
What it collects
For each cache operation:
| Field | Description |
|---|---|
operation | GET_HIT, GET_MISS, SET, or DEL |
key | Cache key |
duration | Operation duration in ms |
startedAt | Unix timestamp |
The panel also displays an aggregated hit/miss ratio.
Toolbar badge
{hits}H/{misses}M (e.g., 8H/2M). When no GET operations: {n}ops.
How it works
At module initialization, the collector wraps the CACHE_MANAGER's get, set, and del methods using a JavaScript Proxy. Each wrapped call records the operation type, key, and duration into the current request profile.