Skip to content

[Lock] - pass redis connection #53845

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
vencakrecl opened this issue Feb 7, 2024 · 5 comments
Open

[Lock] - pass redis connection #53845

vencakrecl opened this issue Feb 7, 2024 · 5 comments

Comments

@vencakrecl
Copy link

vencakrecl commented Feb 7, 2024

Symfony version(s) affected

7.0.3

Description

The StoreFactory can receive object or string but the lock configuration allow use only string. StoreFactory::create can use instance of connection (\Redis, \RedisCluster, etc.)

public static function createStore(#[\SensitiveParameter] object|string $connection): PersistingStoreInterface

How to reproduce

framework:
  lock:
    enabled: true
    resources:
      - '@cache.provider.redis'
      
services:
    cache.provider.redis:
      class: \Redis # no matter what the factory returns
      factory: [ 'Symfony\Component\Cache\Adapter\RedisAdapter', 'createConnection' ]
      arguments:
        - 'redis://redis:6379'

Possible Solution

\Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension::registerLockConfiguration the extension should pass service here.

Additional Context

No response

@mialex
Copy link

mialex commented Jul 24, 2024

In would vote for this one. Have the same issue.
I have already defined a specific Redis provider that I use in other places, like Rate Limiter. This provider has all settings in 1 please. Now I need to create a specific DSN string to pass to Lock just to make it work? It would be really good to reuse my existing provider.

Potentially, it could be achieved with the help of CompilePass to create the Lock storage on the fly, but it would be great to avoid this, as in all other components of Symfony it works by default.

@sgenov
Copy link

sgenov commented Nov 7, 2024

Voting for this as well.
Not only is it simpler, it also solves other issues like sharing Redis between multiple applications. Cache provider allows for a prefix.

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@vencakrecl
Copy link
Author

@carsonbot Yes, it is still relevant.

@carsonbot carsonbot removed the Stalled label May 8, 2025
@xabbuh xabbuh added Feature and removed Bug labels May 8, 2025
@xabbuh
Copy link
Member

xabbuh commented May 8, 2025

PR welcome to implement this

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

No branches or pull requests

5 participants