1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Allow users to disable caching full files

This commit is contained in:
Brown 2020-04-12 08:34:57 -04:00
parent 9d2957d339
commit ee50542b8f
5 changed files with 24 additions and 4 deletions

View File

@ -55,12 +55,18 @@ class ParserCacheProvider
*/
private $new_file_content_hashes = [];
/**
* @var bool
*/
private $use_file_cache;
/** @var bool */
private $use_igbinary;
public function __construct(Config $config)
public function __construct(Config $config, bool $use_file_cache = true)
{
$this->use_igbinary = $config->use_igbinary;
$this->use_file_cache = $use_file_cache;
}
/**
@ -148,6 +154,10 @@ class ParserCacheProvider
*/
public function loadExistingFileContentsFromCache($file_path)
{
if (!$this->use_file_cache) {
return null;
}
$root_cache_directory = Config::getInstance()->getCacheDirectory();
if (!$root_cache_directory) {
@ -298,6 +308,10 @@ class ParserCacheProvider
*/
public function cacheFileContents($file_path, $file_contents)
{
if (!$this->use_file_cache) {
return;
}
$root_cache_directory = Config::getInstance()->getCacheDirectory();
if (!$root_cache_directory) {

View File

@ -369,6 +369,10 @@ Caching:
Runs Psalm without using cached representations of unchanged classes and files.
Useful if you want the afterClassLikeVisit plugin hook to run every time you visit a file.
--no-file-cache
Runs Psalm without using caching every single file for later diffing.
This reduces the space Psalm uses on disk and file I/O.
Miscellaneous:
-h, --help
Display this help message

View File

@ -240,7 +240,7 @@ $threads = isset($options['threads'])
$providers = new Psalm\Internal\Provider\Providers(
new Psalm\Internal\Provider\FileProvider(),
new Psalm\Internal\Provider\ParserCacheProvider($config),
new Psalm\Internal\Provider\ParserCacheProvider($config, false),
new Psalm\Internal\Provider\FileStorageCacheProvider($config),
new Psalm\Internal\Provider\ClassLikeStorageCacheProvider($config)
);

View File

@ -43,6 +43,7 @@ $valid_long_options = [
'monochrome',
'no-cache',
'no-reflection-cache',
'no-file-cache',
'output-format:',
'plugin:',
'report:',
@ -487,6 +488,7 @@ if (isset($options['no-cache']) || isset($options['i'])) {
);
} else {
$no_reflection_cache = isset($options['no-reflection-cache']);
$no_file_cache = isset($options['no-file-cache']);
$file_storage_cache_provider = $no_reflection_cache
? null
@ -498,7 +500,7 @@ if (isset($options['no-cache']) || isset($options['i'])) {
$providers = new Provider\Providers(
new Provider\FileProvider,
new Provider\ParserCacheProvider($config),
new Provider\ParserCacheProvider($config, !$no_file_cache),
$file_storage_cache_provider,
$classlike_storage_cache_provider,
new Provider\FileReferenceCacheProvider($config)

View File

@ -210,7 +210,7 @@ if (isset($options['no-cache'])) {
} else {
$providers = new Psalm\Internal\Provider\Providers(
new Psalm\Internal\Provider\FileProvider(),
new Psalm\Internal\Provider\ParserCacheProvider($config),
new Psalm\Internal\Provider\ParserCacheProvider($config, false),
new Psalm\Internal\Provider\FileStorageCacheProvider($config),
new Psalm\Internal\Provider\ClassLikeStorageCacheProvider($config)
);