Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f91916

Browse files
maxisameneajaho
authored andcommitted
fix(isr): in memory cache handler should use extends #1736
1 parent 17f2ee8 commit 3f91916

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

libs/isr/server/src/cache-handlers/in-memory-cache-handler.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ const defaultCacheISRConfig: CacheISRConfig = {
99
buildId: null,
1010
};
1111

12-
export class InMemoryCacheHandler implements CacheHandler {
12+
export class InMemoryCacheHandler extends CacheHandler {
1313
protected cache = new Map<string, CacheData>();
14+
constructor() {
15+
super();
16+
}
1417

1518
add(
1619
url: string,
1720
html: string,
18-
config: CacheISRConfig = defaultCacheISRConfig
21+
config: CacheISRConfig = defaultCacheISRConfig,
1922
): Promise<void> {
2023
const htmlWithMsg = html + cacheMsg(config.revalidate);
2124

22-
return new Promise((resolve, reject) => {
25+
return new Promise((resolve) => {
2326
const cacheData: CacheData = {
2427
html: htmlWithMsg,
2528
options: config,
@@ -40,22 +43,29 @@ export class InMemoryCacheHandler implements CacheHandler {
4043
}
4144

4245
getAll(): Promise<string[]> {
43-
return new Promise((resolve, reject) => {
46+
return new Promise((resolve) => {
4447
resolve(Array.from(this.cache.keys()));
4548
});
4649
}
4750

4851
has(url: string): Promise<boolean> {
49-
return new Promise((resolve, reject) => {
52+
return new Promise((resolve) => {
5053
resolve(this.cache.has(url));
5154
});
5255
}
5356

5457
delete(url: string): Promise<boolean> {
55-
return new Promise((resolve, reject) => {
58+
return new Promise((resolve) => {
5659
resolve(this.cache.delete(url));
5760
});
5861
}
62+
63+
override clearCache?(): Promise<boolean> {
64+
return new Promise((resolve) => {
65+
this.cache.clear();
66+
resolve(true);
67+
});
68+
}
5969
}
6070

6171
const cacheMsg = (revalidateTime?: number | null): string => {

0 commit comments

Comments
 (0)