limingxinleo / idempotent
多次调用相同函数与单次调用该函数具有相同的效果。
v0.3.1
2023-06-28 03:56 UTC
Requires
- php: >=8.0
- hyperf/contract: ^2.2|^3.0
- jetbrains/phpstorm-attributes: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- hyperf/redis: ^3.0
- hyperf/utils: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- swoole/ide-helper: ^4.7
Suggests
- ext-redis: *
This package is auto-updated.
Last update: 2024-08-28 06:33:21 UTC
README
安装
composer require limingxinleo/idempotent
使用
Hyperf 框架
以下代码将在2秒内返回相同的数据
<?php use Hyperf\Utils\ApplicationContext; use Idempotent\Idempotent; $container = ApplicationContext::getContainer(); $id = 'create_order:1'; $result = $container->get(Idempotent::class)->run($id, static function(){ sleep(2); return uniqid(); }); var_dump($result);