Registry / database / najm-cache

najm-cache

JSON →
library1.2.9jsnpmunverified

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.

npm install najm-cache
INSTALL
IMPORT
SIG · NAJM-CACHE
N
najm-cache
databasejavascriptv1.2.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cache
import { cache } from 'najm-cache'
import cache from 'najm-cache'
Named export, no default export.
CacheService
import { CacheService } from 'najm-cache'
const { CacheService } = require('najm-cache')
ESM-only; require not supported. TypeScript type included.
CacheService constructor
@Injectable() class MyService { constructor(private cache: CacheService) {} }
constructor(private cache: CacheService) {} without @Injectable()
Requires @Injectable() decorator for DI, which needs reflect-metadata polyfill.

Sets up a Najm server with in-memory caching. No Redis setup needed.

import { Server } from 'najm-core'; import { cache } from 'najm-cache'; await new Server() .use(cache()) // defaults to memory .listen(3000);
Debug
Known issues
gotchaMemory cache is single-instance only; use Redis for multi-instance deployments to avoid data inconsistency.
fix
Configure Redis driver with .use(cache({ redis: { url: process.env.REDIS_URL! } }))
affects: >=1.0.0
gotchareflect-metadata must be installed as a peer dependency if using DI decorators like @Injectable().
fix
Install reflect-metadata: bun add reflect-metadata
affects: >=1.0.0
deprecatedioredis is an optional peer dependency; if Redis driver is used without ioredis installed, it will silently fallback to memory.
fix
Install ioredis: bun add ioredis
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'ioredis'
ioredis not installed when using Redis driver.
fix
Install ioredis: bun add ioredis
Cannot find module 'reflect-metadata'
reflect-metadata not installed when using DI decorators.
fix
Install reflect-metadata: bun add reflect-metadata
TypeError: cache is not a function
Attempting default import instead of named import.
fix
Use import { cache } from 'najm-cache'
Upgrade
Version history
1.2.9latest on npm
Audit
Dependencies
reflect-metadataoptionalOptional peer dependency for DI decorator support
ioredisoptionalOptional peer dependency for Redis driver
Agent activity
4 hits · last 30 days
node
4
Resources
najm-cache — npm install najm-cache · libregistry