msheng/yii2-redlock
Composer 安装命令:
composer require msheng/yii2-redlock
包简介
Class for easier Redlock integration
README 文档
README
A redlock for Yii2, distributed locks with Redis
Based on Redlock-rb by Salvatore Sanfilippo and signe redlock-php
Installation
To install run:
composer require "msheng/yii2-redlock:~1.0.0"
Or add this line to require section of composer.json:
"msheng/yii2-redlock": "~1.0.0"
project
Your project need to be an yii2-app-advanced , and here is the guide
main.php
In common/config/main.php or main-local.php
<?php 'components' => [ 'redLock' => [ 'class' => 'msheng\RedLock\RedLock', 'servers' => [ [ 'hostname' => '127.0.0.1', 'port' => 6379, 'timeout' => 0.5, ], [ 'hostname' => '127.0.0.1', 'port' => 6389, 'timeout' => 0.05, ], [ 'hostname' => '127.0.0.1', 'port' => 6399, 'timeout' => 0.05, ] ] ] ],
Usage
<?php $lock = Yii::$app->redLock->lock('hello'); if($lock){ sleep(10); Yii::$app->redLock->unlock($lock); }
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-05