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.
CacheModule
✓ import { CacheModule } from 'clhq-cache-module'
✗ const CacheModule = require('clhq-cache-module').CacheModule
ESM module; CommonJS require may not work with named exports in alpha version
RedisService
✓ import { RedisService } from 'clhq-cache-module'
TypeScript types included; use named import
CacheModule
✓ CacheModule.register({ isGlobal: true })
✗ new CacheModule({ isGlobal: true })
Use static register method for module configuration
Demonstrates registering the CacheModule in NestJS app and using RedisService for basic set/get operations.
import { Module } from '@nestjs/common';
import { CacheModule, RedisService } from 'clhq-cache-module';
@Module({
imports: [
CacheModule.register({
isGlobal: true,
redisUrl: process.env.REDIS_URL ?? 'redis://localhost:6379',
}),
],
})
export class AppModule {}
// In a service:
@Injectable()
export class MyService {
constructor(private readonly redisService: RedisService) {}
async example() {
await this.redisService.set('key', 'value', 60);
const result = await this.redisService.get('key');
console.log(result);
}
}
Debug
Known issues
deprecatedAlpha version: API may change without notice. Avoid production use.fixWait for stable release or pin to specific alpha version with thorough testing.
affects: <=1.1.0-alpha.189
gotchaRedis URL must include protocol (redis://) otherwise connection fails silently.fixSet REDIS_URL environment variable with 'redis://' prefix.
affects: >=1.0.0
breakingDropped support for NestJS <11; peer dep requires @nestjs/common >=11.0.0.fixUpgrade NestJS to v11 or higher.
affects: >=1.1.0-alpha.180
Errors
Common errors & fixes
Cannot find module 'clhq-cache-module' or its corresponding type declarations.
Package not installed or TypeScript strict mode fails due to missing types.
fixnpm install clhq-cache-module@1.1.0-alpha.189 and ensure 'skipLibCheck': false in tsconfig.
Error: Redis connection refused
Redis server not running or wrong connection string.
fixStart Redis server locally or update REDIS_URL environment variable.
Upgrade
Version history
1.1.0-alpha.189latest on npm
Audit
Dependencies
@nestjs/commonrequiredPeer dependency: requires NestJS common >=11.0.0 for decorators and DI