limingxinleo / idempotent
Making multiple identical function calls has the same effect as making a single function call.
Installs: 1 612
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 0
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-11-28 06:56:15 UTC
README
安装
composer require limingxinleo/idempotent
使用
Hyperf 框架
以下代码会在 2s 内返回相同的数据
<?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);