dennis/php-redis-lock
Composer 安装命令:
composer require dennis/php-redis-lock
包简介
README 文档
README
Connecting to Redis:
RedisLock::connect('tcp://host:port');
Or to just connect to localhost and default port:
RedisLock::connect();
Acquiring a Lock:
$lock = RedisLock::lock('resource');
if($lock) {
doSomething();
}
This will attempt to acquire a lock for the named resource. If successful, the return value is a RedisLock object. If the resource was already locked, the return value will be +false+.
Releasing the Lock:
RedisLock::release($lock);
Make sure to release the lock once you're done with it, so another client can acquire it.
Lock Expiration
If your client acquires a lock and then dies before releasing it, the lock will expire after a certain amount of time (default 5 minutes). You can set your own lock expiration when acquiring the lock like so: $lock = RedisLock::lock('resource', $expiration_in_seconds);
统计信息
- 总下载量: 6.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-02-12