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

CachedConfigCollection is written to disk on every page load #89

Merged
merged 9 commits into from
Jul 18, 2023

Conversation

lekoala
Copy link
Contributor

@lekoala lekoala commented Jun 25, 2023

Another attempt at fixing #34

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible - we're setting the hash any time we get or fetch the full config from the cache, and then on destruct we only set the cache in the event we've changed config and not already updated the cache.

Just one question, which is about tests - in the previous attempt at fixing this, there was an update to the tests - which does have some calls expecting the set() method for the cache to be called some number of times.
It seems a little concerning that those tests are passing without change here - can you please just have a quick look to check if there's a way we can validate this change with unit testing?

@lekoala
Copy link
Contributor Author

lekoala commented Jul 4, 2023

@GuySartorelli yes that makes sense, it the current test, some changes are made, and therefore, it's still written twice

to prove that what i did does something, a unit test should be added where no changes are made and no extra write happens.

@GuySartorelli
Copy link
Member

Sweet. I think that's the only thing holding this PR up now. Do you feel comfortable writing that test?

@lekoala
Copy link
Contributor Author

lekoala commented Jul 5, 2023

@GuySartorelli ok, added the test. It's not very intuitive because any ->get calls update the callCache in the unit tests (so even if you don't actively ->set anything, you still get a write on destruct). It's only once the callCache is already warmed up that no more write will occur.

@lekoala
Copy link
Contributor Author

lekoala commented Jul 11, 2023

@GuySartorelli any other wishes :-) ?

@GuySartorelli
Copy link
Member

This PR is in our peer review column, just waiting for someone on the team to free up to take a proper look.

src/Collections/CachedConfigCollection.php Outdated Show resolved Hide resolved
src/Collections/CachedConfigCollection.php Outdated Show resolved Hide resolved
tests/Collections/CachedConfigCollectionTest.php Outdated Show resolved Hide resolved
tests/Collections/CachedConfigCollectionTest.php Outdated Show resolved Hide resolved
@lekoala
Copy link
Contributor Author

lekoala commented Jul 17, 2023

@emteknetnz ok i've split the test and renamed them in a more meaningful way

@emteknetnz emteknetnz merged commit 44769a6 into silverstripe:2 Jul 18, 2023
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

Successfully merging this pull request may close these issues.

3 participants