diff --git a/components/lock.rst b/components/lock.rst index bac1f835b9a..3332d24fe32 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -108,12 +108,10 @@ to handle the rest of the job:: use App\Lock\RefreshTaxonomy; use Symfony\Component\Lock\Key; - use Symfony\Component\Lock\Lock; $key = new Key('article.'.$article->getId()); - $lock = new Lock( + $lock = $factory->createLockFromKey( $key, - $this->store, 300, // ttl false // autoRelease ); @@ -124,7 +122,7 @@ to handle the rest of the job:: .. note:: Don't forget to set the ``autoRelease`` argument to ``false`` in the - ``Lock`` constructor to avoid releasing the lock when the destructor is + ``Lock`` instantiation to avoid releasing the lock when the destructor is called. Not all stores are compatible with serialization and cross-process locking: for @@ -402,20 +400,20 @@ Locks are created and managed in ``Stores``, which are classes that implement The component includes the following built-in store types: -========================================================== ====== ======== ======== ======= -Store Scope Blocking Expiring Sharing -========================================================== ====== ======== ======== ======= -:ref:`FlockStore ` local yes no yes -:ref:`MemcachedStore ` remote no yes no -:ref:`MongoDbStore ` remote no yes no -:ref:`PdoStore ` remote no yes no -:ref:`DoctrineDbalStore ` remote no yes no -:ref:`PostgreSqlStore ` remote yes no yes -:ref:`DoctrineDbalPostgreSqlStore ` remote yes no yes -:ref:`RedisStore ` remote no yes yes -:ref:`SemaphoreStore ` local yes no no -:ref:`ZookeeperStore ` remote no no no -========================================================== ====== ======== ======== ======= +========================================================== ====== ======== ======== ======= ============= +Store Scope Blocking Expiring Sharing Serialization +========================================================== ====== ======== ======== ======= ============= +:ref:`FlockStore ` local yes no yes no +:ref:`MemcachedStore ` remote no yes no yes +:ref:`MongoDbStore ` remote no yes no yes +:ref:`PdoStore ` remote no yes no yes +:ref:`DoctrineDbalStore ` remote no yes no yes +:ref:`PostgreSqlStore ` remote yes no yes no +:ref:`DoctrineDbalPostgreSqlStore ` remote yes no yes no +:ref:`RedisStore ` remote no yes yes yes +:ref:`SemaphoreStore ` local yes no no no +:ref:`ZookeeperStore ` remote no no no no +========================================================== ====== ======== ======== ======= ============= .. tip::