Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/cubejs-server-core/src/core/CompilerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@
ttl: options.maxCompilerCacheKeepAlive,
updateAgeOnGet: options.updateCompilerCacheKeepAlive
});

// proactively free up old cache values occasionally
if (this.options.maxCompilerCacheKeepAlive) {
this.compiledScriptCacheInterval = setInterval(
() => this.compiledScriptCache.purgeStale(),
this.options.maxCompilerCacheKeepAlive
);
}
}

dispose() {

Check warning on line 48 in packages/cubejs-server-core/src/core/CompilerApi.js

View check run for this annotation

Codecov / codecov/patch

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

Added line #L48 was not covered by tests
if (this.compiledScriptCacheInterval) {
clearInterval(this.compiledScriptCacheInterval);

Check warning on line 50 in packages/cubejs-server-core/src/core/CompilerApi.js

View check run for this annotation

Codecov / codecov/patch

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

Added line #L50 was not covered by tests
}
}

setGraphQLSchema(schema) {
Expand Down
4 changes: 3 additions & 1 deletion packages/cubejs-server-core/src/core/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@
this.compilerCache = new LRUCache<string, CompilerApi>({
max: this.options.compilerCacheSize || 250,
ttl: this.options.maxCompilerCacheKeepAlive,
updateAgeOnGet: this.options.updateCompilerCacheKeepAlive
updateAgeOnGet: this.options.updateCompilerCacheKeepAlive,
// needed to clear the setInterval timer for proactive cache internal cleanups
dispose: (v) => v.dispose(),

Check warning on line 209 in packages/cubejs-server-core/src/core/server.ts

View check run for this annotation

Codecov / codecov/patch

packages/cubejs-server-core/src/core/server.ts#L209

Added line #L209 was not covered by tests
});

if (this.options.contextToAppId) {
Expand All @@ -224,7 +226,7 @@
// proactively free up old cache values occasionally
if (this.options.maxCompilerCacheKeepAlive) {
this.maxCompilerCacheKeep = setInterval(
() => this.compilerCache.purgeStale(),

Check warning on line 229 in packages/cubejs-server-core/src/core/server.ts

View check run for this annotation

Codecov / codecov/patch

packages/cubejs-server-core/src/core/server.ts#L229

Added line #L229 was not covered by tests
this.options.maxCompilerCacheKeepAlive
);
}
Expand Down Expand Up @@ -554,7 +556,7 @@
await this.orchestratorStorage.releaseConnections();

this.orchestratorStorage.clear();
this.compilerCache.clear();

Check warning on line 559 in packages/cubejs-server-core/src/core/server.ts

View check run for this annotation

Codecov / codecov/patch

packages/cubejs-server-core/src/core/server.ts#L559

Added line #L559 was not covered by tests

this.reloadEnvVariables();

Expand Down
Loading