PHP code example of ixarlie / mutex-bundle

1. Go to this page and download the library: Download ixarlie/mutex-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ixarlie / mutex-bundle example snippets


$bundles = [
    // ...
    IXarlie\MutexBundle\IXarlieMutexBundle::class => ['all' => true],
    // ...
];

#[MutexRequest(service: 'lock.default.factory')]

#[MutexRequest(service: 'lock.main_lock.factory')]

#[MutexRequest(service: 'lock.default.factory', strategy: 'block')]
#[MutexRequest(service: 'lock.default.factory', strategy: 'queue')]
#[MutexRequest(service: 'lock.default.factory', strategy: 'force')]

#[MutexRequest(service: 'lock.default.factory', strategy: 'block')]
#[MutexRequest(service: 'lock.default.factory', strategy: 'block', name: 'lock_name')]

#[MutexRequest(service: 'lock.default.factory', strategy: 'block', message: 'Busy!')]

#[MutexRequest(service: 'lock.default.factory', strategy: 'block', userIsolation: true)]

use IXarlie\MutexBundle\MutexRequest;

class MyController {

    #[MutexRequest(
        service: 'lock.default.factory',
        strategy: 'block',
        name: 'action_name',
        userIsolation: true,
        message: 'Busy!',
        ttl: 20.0
    )]
    public function foo()
    {
        return [];
    }
}