{"id":45525,"library":"nest-cache-manager","title":"NestJS Redis Cache Manager","description":"A NestJS-specific caching library that integrates Redis for response caching. Current stable version is 1.2.4 with a monthly release cadence. It provides a RedisService and a @Cache decorator for controller methods. Unlike generic cache-manager, this package is tailored for NestJS decorators and environment-based configuration (REDIS_HOST, REDIS_PORT). It includes TypeScript types and works with NestJS modules.","status":"active","version":"1.2.4","language":"javascript","source_language":"en","source_url":"https://github.com/omair445/nest-cache-manager","tags":["javascript","nestjs","caching","redis","cache-manager","cache","nestjs-cache-manager","typescript"],"install":[{"cmd":"npm install nest-cache-manager","lang":"bash","label":"npm"},{"cmd":"yarn add nest-cache-manager","lang":"bash","label":"yarn"},{"cmd":"pnpm add nest-cache-manager","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Decorators and NestJS module basics","package":"@nestjs/common","optional":false},{"reason":"Redis client used for caching","package":"redis","optional":false}],"imports":[{"note":"ESM-only; CJS require may work but ESM is recommended.","wrong":"const RedisService = require('nest-cache-manager').RedisService","symbol":"RedisService","correct":"import { RedisService } from 'nest-cache-manager'"},{"note":"Named export, not default. The decorator is used directly.","wrong":"import { CacheDecorator } from 'nest-cache-manager'","symbol":"Cache","correct":"import { Cache } from 'nest-cache-manager'"},{"note":"RedisService is a named export, not default.","wrong":"import RedisService from 'nest-cache-manager'","symbol":"RedisService","correct":"import { RedisService } from 'nest-cache-manager'"}],"quickstart":{"code":"import { Module } from '@nestjs/common';\nimport { RedisService } from 'nest-cache-manager';\n\n@Module({\n  providers: [RedisService],\n  exports: [RedisService],\n})\nexport class CacheModule {}\n\n// In a controller:\nimport { Cache } from 'nest-cache-manager';\nimport { Controller, Get } from '@nestjs/common';\n\n@Controller('items')\nexport class ItemsController {\n  @Get()\n  @Cache('itemsList', 3600)\n  async findAll() {\n    // Business logic\n    return ['item1', 'item2'];\n  }\n}","lang":"typescript","description":"Shows how to set up RedisService in a module and use @Cache decorator on a controller method."},"warnings":[{"fix":"Always provide both arguments: @Cache('myKey', 60).","message":"The @Cache decorator expects exactly two arguments: cacheKey (string) and ttl (number in seconds). Omitting or using wrong types will result in runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set REDIS_HOST and REDIS_PORT in your .env or process.env.","message":"Environment variables REDIS_HOST and REDIS_PORT are read at module initialization. If not set, defaults (localhost:6379) are used.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Wrap the RedisService in a custom module with error handling or health checks.","message":"The package does not handle Redis connection errors. If Redis is unreachable, the server may crash.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"","message":"No known deprecations.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.2.4':21 'base':53 'cach':3,9,16,33,41,70,73,75,78 'cache-manag':40,72 'cadenc':26 'configur':54 'control':36 'current':17 'decor':34,49 'environ':52 'environment-bas':51 'generic':39 'host':56 'includ':60 'integr':12 'javascript':68 'librari':10 'manag':4,42,74,79 'method':37 'modul':67 'month':24 'nestj':1,7,48,66,69,77 'nestjs-cache-manag':76 'nestjs-specif':6 'packag':44 'port':58 'provid':28 'redi':2,13,55,57,71 'redisservic':30 'releas':25 'respons':15 'specif':8 'stabl':18 'tailor':46 'type':62 'typescript':61,80 'unlik':38 'version':19 'work':64","created_at":"2026-06-07T12:55:26.212997+00:00","updated_at":"2026-06-07T12:55:26.212997+00:00","problems":[{"fix":"Run 'npm install nest-cache-manager' and ensure your tsconfig.json includes node_modules types.","cause":"Package not installed or not included in tsconfig.json paths.","error":"Cannot find module 'nest-cache-manager' or its corresponding type declarations."},{"fix":"Apply @Cache only to methods in classes decorated with @Controller().","cause":"Attempting to use the decorator outside of a NestJS controller class.","error":"The @Cache decorator must be used within a NestJS context."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/omair445/nest-cache-manager#readme","github":"https://github.com/omair445/nest-cache-manager","docs":null,"changelog":null,"pypi":null,"npm":"nest-cache-manager","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}