toanppp / php-redis-lock
Access synchronization mechanism.
1.1.0
2022-05-19 04:13 UTC
Requires
- php: >=7.4
- ext-redis: *
This package is auto-updated.
Last update: 2024-12-18 12:37:46 UTC
README
About
Access synchronization mechanism.
Installation
composer require toanppp/php-redis-lock
Methods
RedisLock :: getInstance ( string
host, int
port )
Create or get singleton instance of RedisLock.
$redisLockInstance = RedisLock::getInstance('127.0.0.1', 6379);
RedisLock :: acquire ( string
key, string
| null
type = null
)
Lock a key, with or without type.
$redisLockInstance->acquire('key');
RedisLock :: release ( string
key )
Release a key.
$redisLockInstance->release('key');
RedisLock :: releaseByType ( string
type )
Release a key by type.
$type = 'uniqueKey'; $redisLockInstance->acquire(uniqid(), $type); $redisLockInstance->releaseByType($type);