Skip to content
New issue

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

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

Already on GitHub? # to your account

[12.x] Allow Unit & Backed enums for cache stores #55172

Draft
wants to merge 3 commits into
base: 12.x
Choose a base branch
from

Conversation

michaeldyrynda
Copy link
Contributor

This PR enables us to use BackedEnum and UnitEnum values for cache keys, where previously only strings were possible.

In doing so, we can mitigate against typos when working with cache keys.

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@michaeldyrynda
Copy link
Contributor Author

Opened this as draft so as to get feedback on whether test approach 1 (updating existing tests) or 2 (effectively duplicating the tests) is the preferred method.

I'll implement for the other cache stores once a direction is chosen.

@@ -35,48 +36,56 @@ public function __construct(ApcWrapper $apc, $prefix = '')
/**
* Retrieve an item from the cache by key.
*
* @param string $key
* @param \BackedEnum|\UnitEnum|string $key
Copy link
Contributor

@shaedrich shaedrich Mar 26, 2025

Choose a reason for hiding this comment

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

Btw, BackedEnum is a UnitEnum, so I'd say, technically, UnitEnum would suffice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whilst technically true, the use of both in docblocks is consistent with similar behaviour elsewhere in the framework.

@michaeldyrynda michaeldyrynda force-pushed the feature/support-cache-backed-enum branch from 678cdaa to 5073b37 Compare March 26, 2025 23:06
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants