@@ -9,17 +9,20 @@ const defaultCacheISRConfig: CacheISRConfig = {
9
9
buildId : null ,
10
10
} ;
11
11
12
- export class InMemoryCacheHandler implements CacheHandler {
12
+ export class InMemoryCacheHandler extends CacheHandler {
13
13
protected cache = new Map < string , CacheData > ( ) ;
14
+ constructor ( ) {
15
+ super ( ) ;
16
+ }
14
17
15
18
add (
16
19
url : string ,
17
20
html : string ,
18
- config : CacheISRConfig = defaultCacheISRConfig
21
+ config : CacheISRConfig = defaultCacheISRConfig ,
19
22
) : Promise < void > {
20
23
const htmlWithMsg = html + cacheMsg ( config . revalidate ) ;
21
24
22
- return new Promise ( ( resolve , reject ) => {
25
+ return new Promise ( ( resolve ) => {
23
26
const cacheData : CacheData = {
24
27
html : htmlWithMsg ,
25
28
options : config ,
@@ -40,22 +43,29 @@ export class InMemoryCacheHandler implements CacheHandler {
40
43
}
41
44
42
45
getAll ( ) : Promise < string [ ] > {
43
- return new Promise ( ( resolve , reject ) => {
46
+ return new Promise ( ( resolve ) => {
44
47
resolve ( Array . from ( this . cache . keys ( ) ) ) ;
45
48
} ) ;
46
49
}
47
50
48
51
has ( url : string ) : Promise < boolean > {
49
- return new Promise ( ( resolve , reject ) => {
52
+ return new Promise ( ( resolve ) => {
50
53
resolve ( this . cache . has ( url ) ) ;
51
54
} ) ;
52
55
}
53
56
54
57
delete ( url : string ) : Promise < boolean > {
55
- return new Promise ( ( resolve , reject ) => {
58
+ return new Promise ( ( resolve ) => {
56
59
resolve ( this . cache . delete ( url ) ) ;
57
60
} ) ;
58
61
}
62
+
63
+ override clearCache ?( ) : Promise < boolean > {
64
+ return new Promise ( ( resolve ) => {
65
+ this . cache . clear ( ) ;
66
+ resolve ( true ) ;
67
+ } ) ;
68
+ }
59
69
}
60
70
61
71
const cacheMsg = ( revalidateTime ?: number | null ) : string => {
0 commit comments