wallet
This commit is contained in:
30
app/Cache/Lock/BaseLock.php
Normal file
30
app/Cache/Lock/BaseLock.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
13
app/Cache/Lock/WalletPlatformUserTransactionLock.php
Normal file
13
app/Cache/Lock/WalletPlatformUserTransactionLock.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace App\Cache\Lock;
|
||||
|
||||
class WalletPlatformUserTransactionLock extends BaseLock
|
||||
{
|
||||
const WITHDRAW_LOCK_KEY = 'wallet_platform_user_transaction_withdraw_lock:';
|
||||
|
||||
public static function getWithdrawKey($id): string
|
||||
{
|
||||
return self::WITHDRAW_LOCK_KEY . $id;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user