https://github.com/toanppp/php-redis-lock
Access synchronization mechanism
https://github.com/toanppp/php-redis-lock
distributed-lock php redis
Last synced: 2 months ago
JSON representation
Access synchronization mechanism
- Host: GitHub
- URL: https://github.com/toanppp/php-redis-lock
- Owner: toanppp
- License: mit
- Created: 2022-05-15T04:46:52.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-18T08:51:40.000Z (over 3 years ago)
- Last Synced: 2026-01-11T14:43:24.953Z (6 months ago)
- Topics: distributed-lock, php, redis
- Language: PHP
- Homepage: https://packagist.org/packages/toanppp/php-redis-lock
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHP Redis Lock
## About
Access synchronization mechanism.
## Installation
```shell
composer require toanppp/php-redis-lock
```
## Methods
### RedisLock :: getInstance ( `string` host, `int` port )
Create or get singleton instance of RedisLock.
```php
$redisLockInstance = RedisLock::getInstance('127.0.0.1', 6379);
```
### RedisLock :: acquire ( `string` key, `string` | `null` type = `null` )
Lock a key, with or without type.
```php
$redisLockInstance->acquire('key');
```
### RedisLock :: release ( `string` key )
Release a key.
```php
$redisLockInstance->release('key');
```
### RedisLock :: releaseByType ( `string` type )
Release a key by type.
```php
$type = 'uniqueKey';
$redisLockInstance->acquire(uniqid(), $type);
$redisLockInstance->releaseByType($type);
```