https://github.com/tinywan/webman-lock
based on lua script redis lock for webman plugin
https://github.com/tinywan/webman-lock
lock redis redis-lock tinywan webman workerman
Last synced: 10 months ago
JSON representation
based on lua script redis lock for webman plugin
- Host: GitHub
- URL: https://github.com/tinywan/webman-lock
- Owner: Tinywan
- Created: 2022-06-07T08:39:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-12T09:51:39.000Z (almost 2 years ago)
- Last Synced: 2024-11-09T09:47:08.703Z (over 1 year ago)
- Topics: lock, redis, redis-lock, tinywan, webman, workerman
- Language: PHP
- Homepage:
- Size: 7.81 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# based on lua script redis lock for webman plugin
[](https://packagist.org/packages/tinywan/webman-lock)
[](https://packagist.org/packages/tinywan/webman-lock)
[](https://packagist.org/packages/tinywan/webman-lock)
[](https://packagist.org/packages/tinywan/webman-lock)
[](https://packagist.org/packages/tinywan/webman-lock)
## 安装
```shell
composer require tinywan/webman-lock
```
## 使用
```php
// 锁名称
$lockName = md5((string) time());
// 锁标识
$lockId = \Tinywan\Lock\RedisLock::acquire($lockName);
if (!$lockId) {
return '未获得锁标识,请稍后再试';
}
// 业务处理
// 释放锁
\Tinywan\Lock\RedisLock::release($lockName, $lockId);
```