Add "CodeQL: Trim Cache" using new mode parameter of evaluation/clearCache#2931
Add "CodeQL: Trim Cache" using new mode parameter of evaluation/clearCache#2931
evaluation/clearCache#2931Conversation
…rCache` The purpose of this change is to add a command to clear the cache except for `cached` predicates. This is the same behaviour as `codeql database cleanup --mode=normal`. In contrast, the existing "CodeQL: Clear Cache" corresponds to `--mode=brutal`. This change depends on adding a new `mode` parameter to the `evaluation/clearCache` method of the query server. This is the same method that the existing "CodeQL: Clear Cache" command targets, which means that this solution will not fail when used with older query servers but will have the same behaviour as the existing command. This somewhat decouples the release process of the VSCode extension and the CodeQL release. Testing done so far: manual (VSCode extension debug run). I haven't seen automated tests for the other command either. As part of adding the new "mode" parameter to the clearCache method, the official query server spec will need to be updated to match `new-messages.ts` here.
aeisenberg
left a comment
There was a problem hiding this comment.
Looks reasonable. I have a couple of minor suggestions.
| } | ||
|
|
||
| private async handleClearCache(): Promise<void> { | ||
| private async handleClearCache(mode: "trim" | "clear"): Promise<void> { |
There was a problem hiding this comment.
It would be nice to extract "trim" | "clear" into a type so it can be reused below.
| * Trim the cache down to the configured size, but *within* this limit keep anything that | ||
| * appears to be even possibly potentially useful in the future. | ||
| */ | ||
| export const LIGHT = 2; |
There was a problem hiding this comment.
Are there plans to support LIGHT and GENTLE in the future?
There was a problem hiding this comment.
Probably not, as they're pretty obscure and there's little practical reason to support them in VSCode. Also, we're renaming "brutal" → "clear" and "normal" → "trim" to be more in line with the VSCode commands, so if you have suggestions on new names for "light" and "gentle", I'm all ears :)
| mode: { | ||
| trim: CacheTrimmingMode.NORMAL, | ||
| clear: CacheTrimmingMode.BRUTAL, | ||
| }[mode], |
There was a problem hiding this comment.
Minor: could you extract this to a function? I find this hard to read.
|
Closing this PR in favour of the approach taken in #2928 |
The purpose of this change is to add a command to clear the cache
except for
cachedpredicates. This is thesame behaviour as
codeql database cleanup --mode=normal.In contrast, the existing "CodeQL: Clear Cache" corresponds to
--mode=brutal.This change depends on adding a new
modeparameter to theevaluation/clearCachemethod of the query server. This is the samemethod that the existing "CodeQL: Clear Cache" command targets, which means
that this solution will not fail when used with older query servers
but will have the same behaviour as the existing command.
This somewhat decouples the release process of the VSCode extension and
the CodeQL release.
Testing done so far: manual (VSCode extension debug run). I haven't seen
automated tests for the other command either.
As part of adding the new "mode" parameter to the clearCache method, the
official query server spec will need to be updated to match
new-messages.tshere.
Checklist
ready-for-doc-reviewlabel there.