Gathering detailed insights and metrics for @anchan828/nest-cache-manager-ioredis
Gathering detailed insights and metrics for @anchan828/nest-cache-manager-ioredis
Gathering detailed insights and metrics for @anchan828/nest-cache-manager-ioredis
Gathering detailed insights and metrics for @anchan828/nest-cache-manager-ioredis
npm install @anchan828/nest-cache-manager-ioredis
Typescript
Module System
Node Version
NPM Version
TypeScript (96.04%)
JavaScript (3.96%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2 Stars
1,336 Commits
3 Watchers
4 Branches
2 Contributors
Updated on Jan 28, 2025
Latest Version
3.1.28
Package Id
@anchan828/nest-cache-manager-ioredis@3.1.28
Unpacked Size
24.22 kB
Size
4.73 kB
File Count
19
NPM Version
lerna/3.11.0/node@v20.18.1+x64 (linux)
Node Version
20.18.1
Published on
Jan 26, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
A cache module for Nest framework (node.js) https://nestjs.com/
1$ npm i --save @anchan828/nest-cache
1@Module({ 2 imports: [CacheModule.register()], 3}) 4export class AppModule {}
1@Injectable() 2export class ExampleService { 3 constructor(private readonly cacheService: CacheService) {} 4 5 private items: Item[] = Array(5) 6 .fill(0) 7 .map((_, index) => ({ id: index, name: `Item ${index}` })); 8 9 public async getItems(userId: number): Promise<Item[]> { 10 const cacheKey = `users/${userId}/items`; 11 12 const cache = await this.cacheService.get<Item[]>(cacheKey); 13 14 if (cache) { 15 return cache; 16 } 17 18 await this.cacheService.set(cacheKey, this.items); 19 20 return this.items; 21 } 22}
You can add middleware that is executed just before calling the cache method. It can be used as an interceptor to process the cache key or the value to be stored, or to define dependencies on the cache to manipulate other caches under certain conditions.
1@Injectable() 2export class ExampleService { 3 constructor(private readonly cacheService: CacheService) {} 4 5 public async update(userId: number, age: number): Promise<void> { 6 await this.cacheService.set(`users/${userId}`, age, 10, { 7 /** 8 * You can pass information to be processed under specific conditions used in middleware. 9 */ 10 source: { userId }, 11 }); 12 } 13} 14 15@CacheMiddleware({ 16 /** 17 * The priority of the middleware. The higher the number, the low the priority. 18 */ 19 priority: 1, 20}) 21class TestCacheMiddleware implements ICacheMiddleware { 22 constructor(private readonly cacheService: CacheService) {} 23 /** 24 * If you want to set a hook for set, implement the set method. 25 */ 26 async set(context: CacheContext<"set">): Promise<void> { 27 /** 28 * Change data 29 */ 30 context.key = `version-1/${context.key}`; 31 context.value = { data: context.value }; 32 context.ttl = 1000; 33 34 /** 35 * Get the source passed from the set method 36 */ 37 const source = context.getSource<{ userId: number }>(); 38 39 /** 40 * Manage other caches under certain conditions 41 */ 42 if (source?.userId === 1) { 43 this.cacheService.delete("another-cache-key"); 44 } 45 } 46 47 /** 48 * You can define middleware for most methods. 49 */ 50 // ttl?(context: CacheContext<"ttl">): Promise<void>; 51 // delete?(context: CacheContext<"delete">): Promise<void>; 52 // mget?(context: CacheContext<"mget">): Promise<void>; 53 // mset?(context: CacheContext<"mset">): Promise<void>; 54 // mdel?(context: CacheContext<"mdel">): Promise<void>; 55 // hget?(context: CacheContext<"hget">): Promise<void>; 56 // hset?(context: CacheContext<"hset">): Promise<void>; 57 // hdel?(context: CacheContext<"hdel">): Promise<void>; 58 // hgetall?(context: CacheContext<"hgetall">): Promise<void>; 59 // hkeys?(context: CacheContext<"hkeys">): Promise<void>; 60} 61 62@Module({ 63 imports: [CacheModule.register()], 64 prividers: [ 65 /** 66 * Register middleware 67 */ 68 TestCacheMiddleware, 69 ExampleService, 70 ], 71}) 72export class AppModule {}
@anchan828/nest-cache has been extended to make more Redis commands available. In line with this, the memory store also provides compatibility features. Please use @anchan828/nest-cache-manager-memory instead of the default memory store.
1import { memoryStore } from "@anchan828/nest-cache-manager-memory"; 2 3@Module({ 4 imports: [ 5 CacheModule.register({ 6 store: memoryStore, 7 }), 8 ], 9}) 10export class AppModule {}
You can use Redis instead of in-memory cache. Please use @anchan828/nest-cache-manager-ioredis
@anchan828/nest-cache-manager-ioredis has the ability to cache Redis results in AsyncLocalStorage. This is useful for elements that need to be accessed frequently.
1import { redisStore } from "@anchan828/nest-cache-manager-ioredis"; 2const asyncLocalStorage = new AsyncLocalStorage<Map<string, any>>(); 3@Module({ 4 imports: [ 5 CacheModule.register({ 6 store: redisStore, 7 host: "localhost", 8 asyncLocalStorage, 9 }), 10 ], 11}) 12export class AppModule {}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
project is archived
Details
Reason
Found 0/3 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More