Skip to content

Commit 8bc8a66

Browse files
committed
Clear/delete funksjoner for redis
1 parent a08bc61 commit 8bc8a66

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

server/cache/custom-cache-handler.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ export default class CustomFileSystemCache extends FileSystemCache {
8484

8585
public async clearGlobalCache() {
8686
localCache.clear();
87+
redisCache.clear();
8788
return true;
8889
}
8990

9091
public async deleteGlobalCacheEntry(path: string) {
9192
const pagePath = path === '/' ? '/index' : path;
92-
return localCache.delete(pagePath);
93+
localCache.delete(pagePath);
94+
redisCache.delete(pagePath);
95+
return true;
9396
}
9497
}

server/cache/redis.ts

+10
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ export class RedisCache {
8585
});
8686
}
8787

88+
public async delete(key: string) {
89+
console.log('Clearing redis cache!');
90+
return this.client.del(this.getFullKey(key));
91+
}
92+
93+
public async clear() {
94+
console.log('Clearing redis cache!');
95+
return this.client.flushDb();
96+
}
97+
8898
private getFullKey(key: string) {
8999
return `${this.keyPrefix}_${key}`;
90100
}

0 commit comments

Comments
 (0)