-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: 李铭昕 <715557344@qq.com>
- Loading branch information
1 parent
6377ea7
commit 90feb18
Showing
9 changed files
with
128 additions
and
22 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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of Hyperf. | ||
* | ||
* @link https://www.hyperf.io | ||
* @document https://hyperf.wiki | ||
* @contact group@hyperf.io | ||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
*/ | ||
namespace Hyperf\Redis\Traits; | ||
|
||
use Redis; | ||
use RedisCluster; | ||
|
||
use function Hyperf\Tappable\tap; | ||
|
||
trait MultiExec | ||
{ | ||
/** | ||
* Execute commands in a pipeline. | ||
* | ||
* @return array|Redis | ||
*/ | ||
public function pipeline(callable $callback = null) | ||
{ | ||
$pipeline = $this->__call('pipeline', []); | ||
|
||
return is_null($callback) ? $pipeline : tap($pipeline, $callback)->exec(); | ||
} | ||
|
||
/** | ||
* Execute commands in a transaction. | ||
* | ||
* @return array|Redis|RedisCluster | ||
*/ | ||
public function transaction(callable $callback = null) | ||
{ | ||
$transaction = $this->__call('multi', []); | ||
|
||
return is_null($callback) ? $transaction : tap($transaction, $callback)->exec(); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of Hyperf. | ||
* | ||
* @link https://www.hyperf.io | ||
* @document https://hyperf.wiki | ||
* @contact group@hyperf.io | ||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
*/ | ||
namespace Hyperf\Redis\Traits; | ||
|
||
trait ScanCaller | ||
{ | ||
public function scan(&$cursor, ...$arguments) | ||
{ | ||
return $this->__call('scan', array_merge([&$cursor], $arguments)); | ||
} | ||
|
||
public function hScan($key, &$cursor, ...$arguments) | ||
{ | ||
return $this->__call('hScan', array_merge([$key, &$cursor], $arguments)); | ||
} | ||
|
||
public function zScan($key, &$cursor, ...$arguments) | ||
{ | ||
return $this->__call('zScan', array_merge([$key, &$cursor], $arguments)); | ||
} | ||
|
||
public function sScan($key, &$cursor, ...$arguments) | ||
{ | ||
return $this->__call('sScan', array_merge([$key, &$cursor], $arguments)); | ||
} | ||
} |
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