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] Enable namespace-based invalidation by prefixing keys with backend-native namespace separators#59813

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

Merged
nicolas-grekas merged 1 commit intosymfony:7.3fromnicolas-grekas:cache-ns-relax
Mar 23, 2025

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedFeb 19, 2025
edited
Loading

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#45599
LicenseMIT

This PR adds aNamespacedPoolInterface that describes how one can add namespace prefixes to cache pool keys.

This solves#45599 by allowing to use the: separator for Redis:

$cache->withSubNamespace('some-prefix')->get($key,fn () =>...);

Most importantly, this enables namespace-based cache invalidation, typically with namespaces generated by hashing some context.

kaznovac and mtarld reacted with thumbs up emojialexandre-le-borgne reacted with hooray emojikaznovac reacted with heart emoji
@stof
Copy link
Member

IfpushNamespace returns a new adapter, what is the use case forpopNamespace (which also returns a new adapter, and so won't return the "parent" ArrayAdapter for instance) ?

@nicolas-grekas
Copy link
MemberAuthor

@stof you're totally right! I removedpopNamespace and renamed thepushNamespace method towithSubNamespace.

@nicolas-grekasnicolas-grekasforce-pushed thecache-ns-relax branch 4 times, most recently from904427d to349fa7bCompareFebruary 20, 2025 09:51
@nicolas-grekas
Copy link
MemberAuthor

Ready. Tests should be green after merge.

@nicolas-grekasnicolas-grekasforce-pushed thecache-ns-relax branch 2 times, most recently fromb733583 to80e4605CompareFebruary 21, 2025 07:52
@nicolas-grekasnicolas-grekasforce-pushed thecache-ns-relax branch 3 times, most recently fromda4eacf tob9b63deCompareMarch 13, 2025 15:23
@nicolas-grekas
Copy link
MemberAuthor

PR ready (failures will be fixed by merging)

@nicolas-grekas
Copy link
MemberAuthor

Any comment @symfony/mergers ?

Copy link
Member

@kbondkbond left a comment

Choose a reason for hiding this comment

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

❤️

@nicolas-grekasnicolas-grekas merged commit6ef1ab4 intosymfony:7.3Mar 23, 2025
8 of 11 checks passed
@nicolas-grekasnicolas-grekas deleted the cache-ns-relax branchMarch 23, 2025 17:41
@fabpotfabpot mentioned this pull requestMay 2, 2025
@IndraGunawan
Copy link
Contributor

thanks for this great feature@nicolas-grekas

what type-hint that should we use in the constructor to have this ability with autowiring? orNamespacedPoolInterface should be extendsCacheInterface ?

@nicolas-grekas
Copy link
MemberAuthor

Can you try using an intersection type of both? That should work!

@IndraGunawan
Copy link
Contributor

i did (https://symfony-devs.slack.com/archives/C3EQ7S3MJ/p1748498675962069?thread_ts=1748446854.832469&cid=C3EQ7S3MJ) but it does not work

[Symfony\Component\DependencyInjection\Exception\RuntimeException]                                                                                                                                                    Cannot autowire service"App\Command\TestCommand": argument"$appCache" of method"__construct()" hastype"Symfony\Contracts\Cache\CacheInterface&Symfony\Contracts\Cache\NamespacedPoolInterface" but this class     was not found.

@nicolas-grekas
Copy link
MemberAuthor

Can you open an issue?

IndraGunawan reacted with thumbs up emoji

@IndraGunawan
Copy link
Contributor

issue created#60583

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

Reviewers

@stofstofstof left review comments

@kbondkbondkbond approved these changes

+1 more reviewer

@andrew-dembandrew-dembandrew-demb left review comments

Reviewers whose approvals may not affect merge requirements

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

@nicolas-grekas@stof@IndraGunawan@kbond@andrew-demb@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp