From 5efa57ab0283aba3c93a140de5684ddbe94f77c9 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 17 Aug 2026 13:56:10 +0200 Subject: [PATCH] [Caching] Drop MemoryCacheStorage, always use FileCacheStorage --- src/Caching/CacheFactory.php | 8 --- .../Storage/MemoryCacheStorage.php | 52 ------------------- 2 files changed, 60 deletions(-) delete mode 100644 src/Caching/ValueObject/Storage/MemoryCacheStorage.php diff --git a/src/Caching/CacheFactory.php b/src/Caching/CacheFactory.php index 61d2dfd0dc4..eb1ec6f7b02 100644 --- a/src/Caching/CacheFactory.php +++ b/src/Caching/CacheFactory.php @@ -4,9 +4,7 @@ namespace Rector\Caching; -use OndraM\CiDetector\CiDetector; use Rector\Caching\ValueObject\Storage\FileCacheStorage; -use Rector\Caching\ValueObject\Storage\MemoryCacheStorage; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; use Symfony\Component\Filesystem\Filesystem; @@ -23,12 +21,6 @@ public function __construct( */ public function create(): Cache { - // in CI the workspace is ephemeral and usually starts from scratch, - // so a file cache that is never read again is only wasted IO → use faster in-memory cache - if (new CiDetector()->isCiDetected()) { - return new Cache(new MemoryCacheStorage()); - } - $cacheDirectory = SimpleParameterProvider::provideStringParameter(Option::CACHE_DIR); // ensure cache directory exists diff --git a/src/Caching/ValueObject/Storage/MemoryCacheStorage.php b/src/Caching/ValueObject/Storage/MemoryCacheStorage.php deleted file mode 100644 index c3e4ecf1a31..00000000000 --- a/src/Caching/ValueObject/Storage/MemoryCacheStorage.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ - private array $storage = []; - - public function load(string $key, string $variableKey): mixed - { - if (! isset($this->storage[$key])) { - return null; - } - - $item = $this->storage[$key]; - if (! $item->isVariableKeyValid($variableKey)) { - return null; - } - - return $item->getData(); - } - - public function save(string $key, string $variableKey, mixed $data): void - { - $this->storage[$key] = new CacheItem($variableKey, $data); - } - - public function clean(string $key): void - { - if (! isset($this->storage[$key])) { - return; - } - - unset($this->storage[$key]); - } - - public function clear(): void - { - $this->storage = []; - } -}