1. Go to this page and download the library: Download ezijng/hyperf-redlock library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
//参考 RedlockHyperf\Aspect\RedLockAspect
if ($lock) {
//to release lock when server receive exit sign
Coroutine::create(function () use ($lock) {
$exited = CoordinatorManager::until(Constants::WORKER_EXIT)->yield($lock['validity']);
$exited && $this->redlock->unlock($lock);
});
//do your code
$this->redlock->unlock($lock);
return $result;
}
class IndexController extends AbstractController
{
/**
* @RedLockAnnotation(resource="redlock-hyperf-test", poolName={"default"})
*/
public function index() {}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.