@@ -62,6 +62,8 @@ this behavior by using the ``lock`` key like:
62
62
lock : ' oci:host=127.0.0.1;dbname=app'
63
63
lock : ' mongodb://127.0.0.1/app?collection=lock'
64
64
lock : ' %env(LOCK_DSN)%'
65
+ # using an existing service
66
+ lock : ' snc_redis.default'
65
67
66
68
# named locks
67
69
lock :
@@ -119,6 +121,9 @@ this behavior by using the ``lock`` key like:
119
121
120
122
<framework : resource >%env(LOCK_DSN)%</framework : resource >
121
123
124
+ <!-- using an existing service -->
125
+ <framework : resource >snc_redis.default</framework : resource >
126
+
122
127
<!-- named locks -->
123
128
<framework : resource name =" invoice" >semaphore</framework : resource >
124
129
<framework : resource name =" invoice" >redis://r2.docker</framework : resource >
@@ -130,6 +135,7 @@ this behavior by using the ``lock`` key like:
130
135
.. code-block :: php
131
136
132
137
// config/packages/lock.php
138
+ use function Symfony\Component\DependencyInjection\Loader\Configurator\env;
133
139
use Symfony\Config\FrameworkConfig;
134
140
135
141
return static function (FrameworkConfig $framework): void {
@@ -152,13 +158,19 @@ this behavior by using the ``lock`` key like:
152
158
->resource('default', ['oci:host=127.0.0.1;dbname=app'])
153
159
->resource('default', ['mongodb://127.0.0.1/app?collection=lock'])
154
160
->resource('default', [env('LOCK_DSN')])
161
+ // using an existing service
162
+ ->resource('default', ['snc_redis.default'])
155
163
156
164
// named locks
157
165
->resource('invoice', ['semaphore', 'redis://r2.docker'])
158
166
->resource('report', ['semaphore'])
159
167
;
160
168
};
161
169
170
+ .. versionadded :: 7.2
171
+
172
+ The option to use an existing service as the lock/semaphore was introduced in Symfony 7.2.
173
+
162
174
Locking a Resource
163
175
------------------
164
176
0 commit comments