Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 1.93 KB

lock.md

File metadata and controls

64 lines (45 loc) · 1.93 KB

Lock

This bundle provides a deep integration of the Lock component, by default, each task receive a key once scheduled.

Usage

Given the following framework.yaml file:

# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
    # ...

    lock:
        scheduler: 'sqlite:///%kernel.project_dir%/var/lock.db'

The lock store to use by the TaskLockBagMiddleware can be defined:

scheduler_bundle:
  lock_store: 'lock.scheduler.store'

# ...

PS: As conventions can evolve, you can retrieve the store name using bin/console debug:container store:

$ bin/console debug:container store

Select one of the following services to display its information:
  [0] http_cache.store
  [1] lock.store.combined.abstract
  [2] scheduler.lock_store.factory
  [3] lock.scheduler.store
  [4] Symfony\Component\Lock\PersistingStoreInterface $schedulerLockStore
  [5] lock.default.store
  [6] lock.store
  [7] Symfony\Component\Lock\PersistingStoreInterface
  
  # ...

Default behavior

As explained in the configuration, by default, this bundle creates a FlockStore, even if it's enough in test or dev environment, this store does not support serializing the key (which occurs if you use external transport), consider using a persisting store in production.

Executing tasks

By default, this bundle will lock tasks before executing them, as the default store is FlockStore, tasks can be locked between processes BUT you may want to use an external lock store, as explained earlier, you can easily define a store and set the lock_store to use it.

For more information, see the Worker.

Keep in mind that the store MUST support sharing the key to lock tasks between processes.