foxtech6 / mutex-locker
MutexSafe will help you use mutex more effectively. Different mutex for different components are presented. In addition, you can add your own lockers and use within the library.
Installs: 147
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/foxtech6/mutex-locker
Requires
- php: ^7.1
Requires (Dev)
- predis/predis: ~1.0
- dev-master
- v1.0
- v0.0.2
- v0.0.1
- dev-foxtech6-patch-6
- dev-foxtech6-patch-5
- dev-foxtech6-patch-4
- dev-foxtech6-patch-3
- dev-foxtech6-patch-2
- dev-foxtech6-patch-1
- dev-fix-643
- dev-fix/452
- dev-fix/789
- dev-fix/issue-98
- dev-fix/issue-78
- dev-fix/redis-45
- dev-fix/ussue-43
- dev-sem
- dev-fix/issue-478
- dev-memfix
- dev-fix/memcached
- dev-fix/flock-mutex
- dev-fix/redis
- dev-fix/flock
This package is auto-updated.
Last update: 2025-10-01 06:24:08 UTC
README
Manage locks effectively and faster | With PHP7
- This library will help you use mutex more effectively.
- Different mutex for different components are presented.
- In addition, you can add your own lockers and use within the library.
How to use
$customHandler = new \CustomHandler(/* some parameters */); // You can send the handler directly to the constructor $factory = new \Foxtech\Competitor($customHandler); /* OR */ // via the setHandler method $factory = new \Foxtech\Competitor(); $factory->setHandler($customHandler); $timeout = 50;//seconds $factory->getMutex('mutex_name')->acquire($timeout /* default timeout - 30 seconds */); // some code $factory->getMutex('mutex_name')->release();
You can also write your own mutex to a custom handler and use within our library.(Important: Your mutex must implement our interface)
$yourCustomHandler = new YourCustomHandler(); $factory = new \Foxtech\Competitor(); $factory->push(YourCustomHandler::class, YourMutex::class); $factory->setHandler($yourCustomHandler); $factory->getMutex('mutex_name')->acquire(); // some code $factory->getMutex('mutex_name')->release();
PDO Handler
$pdo = new \PDO('mysql:host=localhost;dbname=test', 'root', 'toor'); $factory = new \Foxtech\Competitor($pdo); $factory->getMutex('mutex_name')->acquire(); // some code $factory->getMutex('mutex_name')->release();