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

Version Cache #6989

Open
wants to merge 4 commits into
base: v5/develop
Choose a base branch
from
Open

Conversation

bastianallgeier
Copy link
Member

@bastianallgeier bastianallgeier commented Feb 10, 2025

Description

Todos

  • Unit tests for the VersionCache class

Summary of changes

  • New Kirby\Content\VersionCache class
  • The cache class is used in the Version class to avoid multiple reads
  • The VersionCache is cleared whenever the App constructor is called

Changelog

Enhancements

  • Multiple storage reads are avoided with a new VersionCache class.

Breaking changes

None

Docs

Ready?

  • In-code documentation (wherever needed)
  • Unit tests for fixed bug/feature
  • Tests and CI checks all pass

For review team

  • Add lab and/or sandbox examples (wherever helpful)
  • Add changes & docs to release notes draft in Notion

@distantnative
Copy link
Member

No full review but to not forget this:
We need to ensure that the key never points to another model. Which right now could happen if in the same request two pages change their slug/id and page B ends up with the cache key of page A.

I wanted to suggest to use it in ::purge() but I realized that ::purge() isn't really used in our real code but mainly by our plugins (which sheds a whole new light on all the unit tests failing because of purge with LabPage if that's really almost just a tests thing).

@bastianallgeier
Copy link
Member Author

@distantnative it's a problem that not all actions go through the Version and Storage classes yet. This is quite a good example for that. I think we really need to go through all the model actions again and check for parts where this could happen.

@bastianallgeier bastianallgeier force-pushed the v5/enhancements/version-cache branch from c1ca9d5 to aae3c87 Compare February 11, 2025 13:23
@bastianallgeier bastianallgeier marked this pull request as ready for review February 11, 2025 14:49
@bastianallgeier bastianallgeier added this to the 5.0.0-rc.1 milestone Feb 13, 2025
Copy link
Member

@distantnative distantnative left a comment

Choose a reason for hiding this comment

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

I'm a bit torn whether I like this global cache instead of model-specific. And sometimes we try to remove/add specific models, sometimes we just hard reset. Doesn't feel fully elegant. But maybe it's an easier compromise to do it that broad.

@bastianallgeier
Copy link
Member Author

To be honest, this has been the approach that felt most straight forward to me. I agree that it is not super elegant though. It is 100% internal though. If you want to give it a go to build a model-based version, that'd be great. But otherwise I think the main objective is to get it done for v5.

Copy link
Member

@distantnative distantnative left a comment

Choose a reason for hiding this comment

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

Probably indeed the most pragmatic approach right now.

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

Successfully merging this pull request may close these issues.

2 participants