{"id":45510,"library":"najm-cache","title":"Najm Cache","description":"Unified cache plugin for the Najm framework (v1.2.9) with in-memory and Redis drivers. Provides automatic fallback to memory when Redis is unavailable. Supports common caching patterns (get/set, JSON, cache-aside, atomic increment). Uses reflect-metadata optionally for dependency injection. Ideal for single-instance (memory) or multi-instance (Redis) deployment. Ships TypeScript types.","status":"active","version":"1.2.9","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","cache","redis","memory","najm","ioredis","key-value","store","typescript"],"install":[{"cmd":"npm install najm-cache","lang":"bash","label":"npm"},{"cmd":"yarn add najm-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add najm-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Optional peer dependency for DI decorator support","package":"reflect-metadata","optional":true},{"reason":"Optional peer dependency for Redis driver","package":"ioredis","optional":true}],"imports":[{"note":"Named export, no default export.","wrong":"import cache from 'najm-cache'","symbol":"cache","correct":"import { cache } from 'najm-cache'"},{"note":"ESM-only; require not supported. TypeScript type included.","wrong":"const { CacheService } = require('najm-cache')","symbol":"CacheService","correct":"import { CacheService } from 'najm-cache'"},{"note":"Requires @Injectable() decorator for DI, which needs reflect-metadata polyfill.","wrong":"constructor(private cache: CacheService) {} without @Injectable()","symbol":"CacheService constructor","correct":"@Injectable() class MyService { constructor(private cache: CacheService) {} }"}],"quickstart":{"code":"import { Server } from 'najm-core';\nimport { cache } from 'najm-cache';\n\nawait new Server()\n  .use(cache())  // defaults to memory\n  .listen(3000);","lang":"typescript","description":"Sets up a Najm server with in-memory caching. No Redis setup needed."},"warnings":[{"fix":"Configure Redis driver with .use(cache({ redis: { url: process.env.REDIS_URL! } }))","message":"Memory cache is single-instance only; use Redis for multi-instance deployments to avoid data inconsistency.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install reflect-metadata: bun add reflect-metadata","message":"reflect-metadata must be installed as a peer dependency if using DI decorators like @Injectable().","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install ioredis: bun add ioredis","message":"ioredis is an optional peer dependency; if Redis driver is used without ioredis installed, it will silently fallback to memory.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'asid':35 'atom':36 'automat':19 'cach':2,4,29,34,62 'cache-asid':33 'common':28 'depend':44 'deploy':57 'driver':17 'fallback':20 'framework':9 'get/set':31 'ideal':46 'in-memori':12 'increment':37 'inject':45 'instanc':50,55 'ioredi':66 'javascript':61 'json':32 'key':68 'key-valu':67 'memori':14,22,51,64 'metadata':41 'multi':54 'multi-inst':53 'najm':1,8,65 'option':42 'pattern':30 'plugin':5 'provid':18 'redi':16,24,56,63 'reflect':40 'reflect-metadata':39 'ship':58 'singl':49 'single-inst':48 'store':70 'support':27 'type':60 'typescript':59,71 'unavail':26 'unifi':3 'use':38 'v1.2.9':10 'valu':69","created_at":"2026-06-07T12:55:22.550561+00:00","updated_at":"2026-06-07T12:55:22.550561+00:00","problems":[{"fix":"Install ioredis: bun add ioredis","cause":"ioredis not installed when using Redis driver.","error":"Cannot find module 'ioredis'"},{"fix":"Install reflect-metadata: bun add reflect-metadata","cause":"reflect-metadata not installed when using DI decorators.","error":"Cannot find module 'reflect-metadata'"},{"fix":"Use import { cache } from 'najm-cache'","cause":"Attempting default import instead of named import.","error":"TypeError: cache is not a function"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"najm-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"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}}