wv / lock
钱包锁
dev-master
2019-10-22 04:36 UTC
Requires
- php: >=7.0.0
- ext-memcached: *
- doctrine/cache: ^1.8
- dusank/knapsack: ^10.0
- pimple/pimple: ^3.2
- predis/predis: ^1.1
This package is auto-updated.
Last update: 2024-10-22 16:17:31 UTC
README
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');