Skip to content

Commit 0fe53cb

Browse files
committed
minor #20738 [FrameworkBundle] Using existing services as lock/semaphore resources (HypeMC)
This PR was merged into the 7.2 branch. Discussion ---------- [FrameworkBundle] Using existing services as lock/semaphore resources Closes #20230 Commits ------- 8b245b2 [FrameworkBundle] Using existing services as lock/semaphore resources
2 parents f2ad12c + 8b245b2 commit 0fe53cb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lock.rst

+8
Original file line numberDiff line numberDiff line change
@@ -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,6 +158,8 @@ 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'])

reference/configuration/framework.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ resources
20482048
**type**: ``array``
20492049

20502050
A map of lock stores to be created by the framework extension, with
2051-
the name as key and DSN as value:
2051+
the name as key and DSN or service id as value:
20522052

20532053
.. configuration-block::
20542054

@@ -2725,7 +2725,7 @@ resources
27252725
**type**: ``array``
27262726

27272727
A map of semaphore stores to be created by the framework extension, with
2728-
the name as key and DSN as value:
2728+
the name as key and DSN or service id as value:
27292729

27302730
.. configuration-block::
27312731

@@ -2756,11 +2756,12 @@ the name as key and DSN as value:
27562756
.. code-block:: php
27572757
27582758
// config/packages/semaphore.php
2759+
use function Symfony\Component\DependencyInjection\Loader\Configurator\env;
27592760
use Symfony\Config\FrameworkConfig;
27602761
27612762
return static function (FrameworkConfig $framework): void {
27622763
$framework->semaphore()
2763-
->resource('default', ['%env(SEMAPHORE_DSN)%']);
2764+
->resource('default', [env('SEMAPHORE_DSN')]);
27642765
};
27652766
27662767
.. _reference-semaphore-resources-name:

0 commit comments

Comments
 (0)