Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions about Rector's cache #6879

Closed
ondrejmirtes opened this issue Dec 19, 2021 · 2 comments
Closed

Questions about Rector's cache #6879

ondrejmirtes opened this issue Dec 19, 2021 · 2 comments

Comments

@ondrejmirtes
Copy link
Contributor

Question

Hi, I've seen some mentions about cache in the source code, namely Option::CACHE_DIR and ChangedFilesDetector. I'd like to know what's the purpose of this cache? When does it get hit?

I'm asking because what I'd like to do is to have fast downgrade run when there are very little changes in the code. Because Rector mostly does the same thing over and over again.

So I'd like to have a cache where there's a structure like "path to file" => {original contents, downgraded contents}. When Rector runs, and sees that the file still has the original content, it doesn't have to execute all the expensive and slow logic, it can just replace the contents of the file with downgraded contents from the cache.

I can build it myself, I'd just like to know if there's something like that already in Rector, and how to use it.

Thanks.

@TomasVotruba
Copy link
Member

Hi, it seems this cache is hit in 2 steps:

I'm asking because what I'd like to do is to have fast downgrade run when there are very little changes in the code. Because Rector mostly does the same thing over and over again.

That's how it should work. If it's not the case, there is probably some bug.

So I'd like to have a cache where there's a structure like "path to file" => {original contents, downgraded contents}. When Rector runs, and sees that the file still has the original content, it doesn't have to execute all the expensive and slow logic, it can just replace the contents of the file with downgraded contents from the cache.

👍

@TomasVotruba
Copy link
Member

TomasVotruba commented Dec 23, 2021

After writing this comment, I realize it's important that this whole cache is invalidated on rector.php config file change. It includes all the imported configs as well.

https://github.com/rectorphp/rector-src/blob/e546dbb45f59843b1a81685be05e5e1fb58b6ed9/packages/Caching/Detector/ChangedFilesDetector.php#L91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants