| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?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();
- }
- }
|