Skip to content

Mr-wangwei/lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

安装

composer require "wv/lock";

使用

use Wei\Lock\Application;

$config = [
    'cache' => [
        'default' => 'redis',
        'stores' => [
            'file' => [
                 'driver' => 'file',
                 'patch'  => __DIR__ . DIRECTORY_SEPARATOR . 'cache',
            ],
            'memcached' => [
                 'server' => '127.0.0.1',
                 'port'   => 11211,
            ],
            'redis' => [
                 'driver'   => 'predis',
                 'host'     => '127.0.0.1',
                 'password' => null,
                 'port'     => 6379,
                 'database' => 0,
            ],
        ],
    ],
];

$app = new Application($config);

//上锁
try {
    $app->lock->setLock('key', 7200, 0);
} catch (\Exception $e) {
    //捕捉异常
}

//释放锁
$app->lock->releaseLock('key');

Releases

No releases published

Packages

No packages published

Languages