File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
packages/cubejs-server-core/src/core Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff line change @@ -204,7 +204,9 @@ export class CubejsServerCore {
204204 this . compilerCache = new LRUCache < string , CompilerApi > ( {
205205 max : this . options . compilerCacheSize || 250 ,
206206 ttl : this . options . maxCompilerCacheKeepAlive ,
207- updateAgeOnGet : this . options . updateCompilerCacheKeepAlive
207+ updateAgeOnGet : this . options . updateCompilerCacheKeepAlive ,
208+ // needed to clear the setInterval timer for proactive cache internal cleanups
209+ dispose : ( v ) => v . dispose ( ) ,
208210 } ) ;
209211
210212 if ( this . options . contextToAppId ) {
You can’t perform that action at this time.
0 commit comments