fix(providence): fix ast cache (prevent from endless expanding); expose amountOfCachedProjects
This commit is contained in:
parent
9827228b83
commit
e0d2a759b6
2 changed files with 5 additions and 4 deletions
|
|
@ -2,4 +2,5 @@
|
||||||
'providence-analytics': minor
|
'providence-analytics': minor
|
||||||
---
|
---
|
||||||
|
|
||||||
use globby again
|
- use globby again
|
||||||
|
- fix ast cache (prevent from endless expanding); expose amountOfCachedProjects
|
||||||
|
|
|
||||||
|
|
@ -146,12 +146,12 @@ export class QueryService {
|
||||||
}
|
}
|
||||||
// In order to prevent running out of memory, there is a limit to the number of
|
// In order to prevent running out of memory, there is a limit to the number of
|
||||||
// project ASTs in cache. For a session running multiple analyzers for reference
|
// project ASTs in cache. For a session running multiple analyzers for reference
|
||||||
// and target projects, we need this number to be at least 2.
|
if (astProjectsDataCache.size >= this.amountOfCachedProjects) {
|
||||||
if (astProjectsDataCache.size >= 2) {
|
astProjectsDataCache.delete(astProjectsDataCache.keys().next().value);
|
||||||
astProjectsDataCache.delete(astProjectsDataCache.keys()[0]);
|
|
||||||
}
|
}
|
||||||
astProjectsDataCache.set(pathAndRequiredAst, astData);
|
astProjectsDataCache.set(pathAndRequiredAst, astData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QueryService.cacheDisabled = false;
|
QueryService.cacheDisabled = false;
|
||||||
|
QueryService.amountOfCachedProjects = 2;
|
||||||
QueryService.addAstToProjectsData = memoize(QueryService.addAstToProjectsData);
|
QueryService.addAstToProjectsData = memoize(QueryService.addAstToProjectsData);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue