-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
171 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
$header = <<<EOF | ||
This file is part of the redisLock package. | ||
Author:Tim Xiao | ||
EOF; | ||
|
||
|
||
return PhpCsFixer\Config::create() | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'@Symfony' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'combine_consecutive_unsets' => true, | ||
// one should use PHPUnit methods to set up expected exception instead of annotations | ||
'general_phpdoc_annotation_remove' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'], | ||
'header_comment' => array('header' => $header), | ||
'heredoc_to_nowdoc' => true, | ||
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'], | ||
'no_unreachable_default_argument_value' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'ordered_class_elements' => true, | ||
'ordered_imports' => true, | ||
'php_unit_strict' => true, | ||
'phpdoc_add_missing_param_annotation' => true, | ||
'no_trailing_comma_in_singleline_array' => true, //单行数组最后一个元素不添加逗号 | ||
'phpdoc_order' => true, | ||
'psr4' => true, | ||
'strict_comparison' => false, | ||
'strict_param' => false, //这里设置为true,发现in_array方法会默认加上第3个参数为true,这使得in_array会对前两个参数值的类型也会做严格的校验,建议设置为false | ||
'binary_operator_spaces' => ['default' => 'align_single_space_minimal'], | ||
//'binary_operator_spaces' => true, | ||
'concat_space' => ['spacing' => 'one'], | ||
'no_empty_statement' => true, | ||
'simplified_null_return' => true, | ||
'no_extra_consecutive_blank_lines' => true, | ||
'pre_increment' => false, //设置为false,$i++ 不会变成 ++$i | ||
'native_function_invocation' => false, //in_array不会加前缀\ | ||
'cast_spaces' => ['space' => 'single'], | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->name('*.php') | ||
->exclude('extend') | ||
->exclude('vendor') | ||
->exclude('FormBase') | ||
->in(__DIR__) | ||
) | ||
->setUsingCache(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
# redisLock | ||
|
||
### | ||
使用redis实现分布式锁 | ||
|
||
### Installation | ||
|
||
### 关于代码格式 | ||
待补充 | ||
|
||
|
||
### 开发指南 | ||
|
||
###### 代码格式 | ||
使用PHP-CS-Fixer格式化代码 | ||
``` | ||
php-cs-fixer fix . | ||
``` | ||
- 参考:https://github.com/FriendsOfPHP/PHP-CS-Fixer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,8 @@ | |
"psr-4": { | ||
"tim1116\\redisLock\\": "src/" | ||
} | ||
}, | ||
"require-dev": { | ||
"eaglewu/swoole-ide-helper": "dev-master" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,22 @@ | ||
<?php | ||
/** | ||
* File: test1.php | ||
* PROJECT_NAME: redisLock | ||
|
||
/* | ||
* This file is part of the redisLock package. | ||
* | ||
* Author:Tim Xiao | ||
*/ | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use tim1116\redisLock\RedisLock; | ||
use tim1116\redisLock\RedisSetting; | ||
|
||
|
||
$config = [ | ||
'host' => '192.168.199.101', | ||
'port' => 6379, | ||
'password' => '123456', | ||
'dbindex' => 6, | ||
]; | ||
$obj = RedisLock::getInstance(new RedisSetting($config)); | ||
//$isLock = $obj->lock("aaa",100); | ||
//var_dump($isLock); | ||
|
||
echo "unlock"; | ||
var_dump($obj->unLock("aaa")); | ||
$isLock = $obj->lock('aaa', 100); | ||
var_dump($isLock); |
Oops, something went wrong.