toanppp / php-redis-lock
Access synchronization mechanism.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/toanppp/php-redis-lock
Requires
- php: >=7.4
- ext-redis: *
This package is auto-updated.
Last update: 2025-10-18 14:24:27 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);