Skip to content

Navigation Menu

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

Appearance settings

[Lock] Add namespace support to Redis & Memcache lock stores #60227

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

Open
wants to merge 4 commits into
base: 7.3
Choose a base branch
Loading
from

Conversation

WaylandAce
Copy link
Contributor

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
License MIT

Sometimes we need use shared redis cluster between applications. By security reasons we allow each application to access only own keys. Cache component can deal with it, lock - is not.

@carsonbot

This comment has been minimized.

@WaylandAce WaylandAce marked this pull request as ready for review April 16, 2025 13:09
@WaylandAce WaylandAce requested a review from jderusse as a code owner April 16, 2025 13:09
@carsonbot carsonbot added this to the 7.3 milestone Apr 16, 2025
src/Symfony/Component/Lock/Store/RedisStore.php Outdated Show resolved Hide resolved
*/
public function __construct(
private \Redis|Relay|RelayCluster|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis,
private float $initialTtl = 300.0,
private array $options = [],
Copy link
Member

Choose a reason for hiding this comment

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

why use an array of options rather than give the namespace directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to use namespace parameter directly, but I tried to keep style similar to other stores (DoctrineDbalStore, MongoDbStore, PdoStore, PostgreSqlStore)

src/Symfony/Component/Lock/Store/MemcachedStore.php Outdated Show resolved Hide resolved
src/Symfony/Component/Lock/Store/MemcachedStore.php Outdated Show resolved Hide resolved
src/Symfony/Component/Lock/Store/MemcachedStore.php Outdated Show resolved Hide resolved
src/Symfony/Component/Lock/Store/MemcachedStore.php Outdated Show resolved Hide resolved

$matches = [];
$namespace = '';
if (preg_match('/^(.*[\?&])namespace=([^&#]*)&?(([^#]*).*)$/', $connection, $matches)) {
Copy link
Member

Choose a reason for hiding this comment

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

can't we use parse_url instead of this logic?

also, don't we need something similar on MemcachedStore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's general to both stores (StoreFactory class).
parse_url cant be used here, because redis dsn string is not always URL format compatible. Also this approach is used in MongoDbStore (collection paramerer), with "options" array as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.