Skip to content

Commit de6e653

Browse files
committed
add proactive cache cleanup
1 parent af7e39d commit de6e653

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/cubejs-server-core/src/core/CompilerApi.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ export class CompilerApi {
3535
ttl: options.maxCompilerCacheKeepAlive,
3636
updateAgeOnGet: options.updateCompilerCacheKeepAlive
3737
});
38+
39+
// proactively free up old cache values occasionally
40+
if (this.options.maxCompilerCacheKeepAlive) {
41+
this.compiledScriptCacheInterval = setInterval(
42+
() => this.compiledScriptCache.purgeStale(),
43+
this.options.maxCompilerCacheKeepAlive
44+
);
45+
}
46+
}
47+
48+
dispose() {
49+
if (this.compiledScriptCacheInterval) {
50+
clearInterval(this.compiledScriptCacheInterval);
51+
}
3852
}
3953

4054
setGraphQLSchema(schema) {

0 commit comments

Comments
 (0)