-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Cache] Allow to use namespace delimiter in cache key #54710
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
[Cache] Allow to use namespace delimiter in cache key #54710
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
This comment has been minimized.
This comment has been minimized.
14fd937
to
fb44d0e
Compare
fb44d0e
to
48176f6
Compare
Not sure how to fix the psalm error or how it popped up. |
IMO, it has two really big drawbacks:
I'd rather add a convenient interface to deal with namespaces instead of permitting the namespace separator in keys. |
Closing in favor of #59813, thanks for giving this a try! |
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.