PHP code example of mauretto78 / locker-manager

1. Go to this page and download the library: Download mauretto78/locker-manager 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/ */

    

mauretto78 / locker-manager example snippets


use LockerManager\Application\LockerManager;
use LockerManager\Infrastructure\FLockerStore;
use LockerManager\Infrastructure\PdoLockerStore;
use LockerManager\Infrastructure\RedisLockerStore;
use Predis\Client;

// Filesystem implementation
$fLockerStore = new FLockerStore('var/lock/');
$lockerManager = new LockerManager($fLockerStore);


// ..

// PDO implementation 
$pdoLockerStore = new PdoLockerStore(new \PDO($config));
$lockerManager = new LockerManager($pdoLockerStore);


// ..

// Redis implementation uses PRedis Client
$redisLockerStore = new RedisLockerStore(new Client($config));
$lockerManager = new LockerManager($redisLockerStore);


// ..

// acquire
$lock = new Lock(
    'Sample Lock',
    [
        'name' => 'John Doe',
        'email' => '[email protected]',
        'age' => 33,
    ]
);

$lockerManager->acquire($lock);

// get a lock
$sampleLock = $lockerManager->get('Sample Lock');

// delete a lock
$lockerManager->delete('Sample Lock');

// update a lock
$lockerManager->update(
    'Sample Lock',
    [
        'name' => 'Maria Dante',
        'email' => '[email protected]',
        'age' => 31,
    ]
);


// ..

$lockerManager->getAll();

// ..

$lockerManager->clear();