Skip to content

Commit 3cd9918

Browse files
committed
fix(lru-redis): ensure default values for lru cache
1 parent 1b026a7 commit 3cd9918

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

storages/lru-redis/src/LRUWithRedisStorage.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ import * as LRU from "lru-cache";
44
import * as Redis from "ioredis";
55

66
export class LRUWithRedisStorage implements AsynchronousCacheType {
7-
myCache: LRU<string, any>;
7+
private myCache: LRU<string, any>;
8+
private options: LRU.Options<string, any>;
89

910
constructor(
10-
private options: LRU.Options<string, any>,
11+
options: LRU.Options<string, any>,
1112
private redis: () => Redis.Redis
1213
) {
13-
this.myCache = new LRU(options);
14+
this.options = {
15+
max: 500,
16+
maxAge: 86400,
17+
...options
18+
}
19+
this.myCache = new LRU(this.options);
1420
}
1521

1622
public async getItem<T>(key: string): Promise<T | undefined> {

0 commit comments

Comments
 (0)