Description
Symfony version(s) affected
7.0.7
Description
The documentation and default config indicate that the cache:clear command uses the system clearer to clear the cache and that the app cache pools should persist between deployments. This does not happen under the default application configuration.
# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
How to reproduce
- Create a new Symfony application
- Add item to the app cache pool
- Run
bin/console cache:clear
Possible Solution
The issue seems to be related to the default configuration setting the kernel.build_dir = kernel.cache_dir.
These lines in Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand will overwrite the entire cache directory with the new build, effectively deleting all cache pools. Interestingly the --no-warmup option causes the pools to get cleared on a different line.
if ($this->isNfs($realBuildDir)) {
$io->note('For better performances, you should move the cache and log directories to a non-shared folder of the VM.');
$fs->remove($realBuildDir);
} else {
$fs->rename($realBuildDir, $oldBuildDir); // <-- loses app pools without --no-warmup
}
$fs->rename($warmupDir, $realBuildDir); //<-- loses app pools with --no-warmup
Additional Context
No response