Deprecate cacheClass(), select cache storage internally - #8311
Draft
TomasVotruba wants to merge 3 commits into
Draft
Deprecate cacheClass(), select cache storage internally#8311TomasVotruba wants to merge 3 commits into
TomasVotruba wants to merge 3 commits into
Conversation
Move the file-vs-memory cache storage decision into CacheFactory: an explicit cacheClass() still wins, otherwise file cache is used locally and in-memory cache in CI, where the ephemeral workspace makes writing a cache that is never re-read wasted IO. Previously this CI branch lived in config/config.php. Mark RectorConfig::cacheClass() and the withCache(cacheClass:) argument as deprecated; they stay functional for the rare case that needs to force a specific storage (e.g. the e2e cache tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ti6vHRo3xLSHw84rxUw6Lb
TomasVotruba
force-pushed
the
claude/deprecate-cache-class-4bavrw
branch
from
August 6, 2026 15:31
1afd62f to
47ddf72
Compare
TomasVotruba
force-pushed
the
claude/deprecate-cache-class-4bavrw
branch
from
August 6, 2026 21:24
8355c2c to
b9b3b51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Moves the file-vs-memory cache storage decision out of user config and into
CacheFactory, and deprecates the publiccacheClass()API.Why
cacheClass()exposed theCacheStorageInterfaceimplementation as a public config knob, but there are only two implementations and only one is ever useful to end users:FileCacheStorage— the real, cross-run cache.MemoryCacheStorage— an in-process array, wiped when the PHP process exits.A Rector CLI run processes every file once in a single process (
hasFileChanged()loads beforecacheFile()saves), so memory storage delivers zero cross-invocation benefit — the whole value of the cache is between runs. SocacheClass()was an implementation detail leaked as public API with no valid production use.How
CacheFactorynow resolves the storage internally: an explicitcacheClass()still wins, otherwise file cache locally and in-memory cache in CI (where the ephemeral workspace makes writing a cache that is never re-read wasted IO). This is the exact policy that previously lived inconfig/config.php, just moved behind the factory — behaviour-preserving.RectorConfig::cacheClass()and thewithCache(cacheClass:)argument are marked#[Deprecated]. They remain functional for the rare case that needs to force a specific storage — e.g. the e2e cache tests, which forceFileCacheStorageso they can verify the persisted cache across two runs even on CI.No new environment variables or config surface. Split out from a combined branch; the
FileCacheStorage::save()simplification is #8312.