[Cache] Allow to use namespace delimiter in cache key #54710
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.
Replaces #51603
This PR allow colon char
:
in cache key. It may be useful for redis grouping keys by pattern without creating a many pools for each namespace.Difference between implementation #47561
@nicolas-grekas I have taken a look at some approaches to how to optimize this, but it looks like:
is pretty well optimized and is marginally faster than
preg_replace
and a lot faster than some otherfor
based approaches I tried. I think the main problem is that this code would need to get executed for each validation, of which there can be many in single http request. So I thought that maybe a different approach would could work - simply allowing override of RESERVED_CHARACTERS via the parameter. Here is a simple test for performance comparison.Here are the results from 5 executions, 1000000 iterations each:
Looks like getting rid of the
str_replace
anstr_split
makes the method about 2x faster.The downside seems relatively small, the logic is moved to the cache adapters. Or we could get rid of the logic completely and just let each adapter define their list of reserved characters..
I am still working on the tests & to ensure that PSR 6 / PSR 16 validation is kept intact.