This commit is contained in:
cano
2024-03-08 00:58:23 +08:00
parent bebbee4184
commit b14c000bc3
25 changed files with 1681 additions and 8 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Cache\Lock;
use Illuminate\Support\Facades\Redis;
class BaseLock
{
const TTL = 120;
function setLockNxEx($key, $value)
{
return Redis::client()->set($key, $value, 'EX', self::TTL, 'NX');
}
function setLock($key, $value = '1')
{
return Redis::client()->setex($key, self::TTL , $value);
}
function unLock($key)
{
return Redis::client()->del($key);
}
function checkLock($key)
{
return Redis::client()->get($key);
}
}