Skip to content

Commit 7f89c8b

Browse files
committed
[FrameworkBundle] Using existing services as lock/semaphore resources
1 parent 44687d8 commit 7f89c8b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lock.rst

Lines changed: 7 additions & 0 deletions
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>
@@ -152,6 +157,8 @@ this behavior by using the ``lock`` key like:
152157
->resource('default', ['oci:host=127.0.0.1;dbname=app'])
153158
->resource('default', ['mongodb://127.0.0.1/app?collection=lock'])
154159
->resource('default', [env('LOCK_DSN')])
160+
// using an existing service
161+
->resource('default', ['snc_redis.default'])
155162
156163
// named locks
157164
->resource('invoice', ['semaphore', 'redis://r2.docker'])

reference/configuration/framework.rst

Lines changed: 5 additions & 3 deletions
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

@@ -2079,6 +2079,7 @@ the name as key and DSN as value:
20792079
.. code-block:: php
20802080
20812081
// config/packages/lock.php
2082+
use function Symfony\Component\DependencyInjection\Loader\Configurator\env;
20822083
use Symfony\Config\FrameworkConfig;
20832084
20842085
return static function (FrameworkConfig $framework): void {
@@ -2725,7 +2726,7 @@ resources
27252726
**type**: ``array``
27262727

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

27302731
.. configuration-block::
27312732

@@ -2756,11 +2757,12 @@ the name as key and DSN as value:
27562757
.. code-block:: php
27572758
27582759
// config/packages/semaphore.php
2760+
use function Symfony\Component\DependencyInjection\Loader\Configurator\env;
27592761
use Symfony\Config\FrameworkConfig;
27602762
27612763
return static function (FrameworkConfig $framework): void {
27622764
$framework->semaphore()
2763-
->resource('default', ['%env(SEMAPHORE_DSN)%']);
2765+
->resource('default', [env('SEMAPHORE_DSN')]);
27642766
};
27652767
27662768
.. _reference-semaphore-resources-name:

0 commit comments

Comments
 (0)