Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Cache] Allow to use namespace delimiter in cache key#51603

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
vtsykun wants to merge1 commit intosymfony:7.3fromvtsykun:feat/cache-1

Conversation

vtsykun
Copy link
Contributor

@vtsykunvtsykun commentedSep 8, 2023
edited by nicolas-grekas
Loading

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#45599
LicenseMIT
Doc PR-

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

  • colon is only allowed for Symfony contracts cache, the PSR-6/16 adapters keeps this validation as before.
  • Allow colon in namespace name too

@carsonbotcarsonbot added this to the6.4 milestoneSep 8, 2023
@vtsykunvtsykunforce-pushed thefeat/cache-1 branch 2 times, most recently from24881eb to94ec24fCompareSeptember 9, 2023 11:28
{
if (!\is_string($key)) {
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', get_debug_type($key)));
}
if ('' === $key) {
throw new InvalidArgumentException('Cache key length must be greater than zero.');
}
if (false !== strpbrk($key, self::RESERVED_CHARACTERS)) {
throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters "%s".', $key, self::RESERVED_CHARACTERS));
$reservedChars = null === $allowChars ? self::RESERVED_CHARACTERS : str_replace(str_split($allowChars), '', self::RESERVED_CHARACTERS);

Choose a reason for hiding this comment

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

would it be possible to get rid of the calls to str_replace and str_split? this is on the hotpath and we'd better make this as fast as possible

@@ -346,7 +346,7 @@ protected function getId(mixed $key): string
if (\is_string($key) && isset($this->ids[$key])) {
return $this->namespace.$this->namespaceVersion.$this->ids[$key];
}
\assert('' !== CacheItem::validateKey($key));
\assert('' !== CacheItem::validateKey($key, static::NS_SEPARATOR));

Choose a reason for hiding this comment

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

this one is used for PSR-6 also, isn't it?

@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@nicolas-grekas
Copy link
Member

@vtsykun up to resume this PR?

@dorrogeray
Copy link
Contributor

It would be great to have this feature 👍 I can try to pick up this PR@vtsykun if you are too busy.

@nicolas-grekas
Copy link
Member

@dorrogeray follow up PR welcome then!

@dorrogeray
Copy link
Contributor

@nicolas-grekas I will work on it this week.

@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@nicolas-grekas
Copy link
Member

Closing in favor of#59813, thanks for giving this a try!

dorrogeray reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

[Cache] Allow colon in key key (with redis at least)
6 participants
@vtsykun@nicolas-grekas@dorrogeray@fabpot@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp