@@ -62,6 +62,8 @@ this behavior by using the ``lock`` key like:
6262 lock : ' oci:host=127.0.0.1;dbname=app'
6363 lock : ' mongodb://127.0.0.1/app?collection=lock'
6464 lock : ' %env(LOCK_DSN)%'
65+ # using an existing service
66+ lock : ' snc_redis.default'
6567
6668 # named locks
6769 lock :
@@ -119,6 +121,9 @@ this behavior by using the ``lock`` key like:
119121
120122 <framework : resource >%env(LOCK_DSN)%</framework : resource >
121123
124+ <!-- using an existing service -->
125+ <framework : resource >snc_redis.default</framework : resource >
126+
122127 <!-- named locks -->
123128 <framework : resource name =" invoice" >semaphore</framework : resource >
124129 <framework : resource name =" invoice" >redis://r2.docker</framework : resource >
@@ -130,6 +135,7 @@ this behavior by using the ``lock`` key like:
130135 .. code-block :: php
131136
132137 // config/packages/lock.php
138+ use function Symfony\Component\DependencyInjection\Loader\Configurator\env;
133139 use Symfony\Config\FrameworkConfig;
134140
135141 return static function (FrameworkConfig $framework): void {
@@ -152,13 +158,19 @@ this behavior by using the ``lock`` key like:
152158 ->resource('default', ['oci:host=127.0.0.1;dbname=app'])
153159 ->resource('default', ['mongodb://127.0.0.1/app?collection=lock'])
154160 ->resource('default', [env('LOCK_DSN')])
161+ // using an existing service
162+ ->resource('default', ['snc_redis.default'])
155163
156164 // named locks
157165 ->resource('invoice', ['semaphore', 'redis://r2.docker'])
158166 ->resource('report', ['semaphore'])
159167 ;
160168 };
161169
170+ .. versionadded :: 7.2
171+
172+ The option to use an existing service as the lock/semaphore was introduced in Symfony 7.2.
173+
162174Locking a Resource
163175------------------
164176
0 commit comments