2017 © Pedro Peláez
 

library idempotent

幂等

image

pfinal/idempotent

幂等

  • Saturday, April 28, 2018
  • by pfinal
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

接口幂等

安装

composer require pfinal/idempotent

创建表


CREATE TABLE `idempotent` ( `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT, `seq` varchar(50) NOT NULL DEFAULT '' COMMENT '请求序号', `response` longtext COMMENT '响应内容', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `ind_seq` (`seq`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '幂等';

调用示例

<?php

include __DIR__ . '/vendor/autoload.php';


//请求唯一标识
$seq = 'c4ca4238a0b923820dcc509a6f75849a';

//数据据库配置信息
\PFinal\Idempotent\Idempotent::$config['db.config'] = [
    'dsn' => 'mysql:host=127.0.0.1;dbname=test',
    'username' => 'root',
    'password' => 'root',
    'charset' => 'utf8',
    'tablePrefix' => '',
];

$result = \PFinal\Idempotent\Idempotent::run($seq, function () {
    //你自己的业务
    return time();
});

//同一个$seq多次请求,将得到相同的结果
echo $result;

The Versions

28/04 2018

dev-master

9999999-dev http://www.pfinal.cn

幂等

  Sources   Download

MIT

The Requires

 

by Zou Yiliang

27/04 2018

v1.0.0

1.0.0.0 http://www.pfinal.cn

幂等

  Sources   Download

MIT

The Requires

 

by Zou Yiliang