bitsbeats/softfailer
Composer 安装命令:
composer require bitsbeats/softfailer
包简介
Library to suppress errors unless they exceed a certain threshold within a given time interval
README 文档
README
PHP library to suppress errors ("soft failures") unless they exceed a certain threshold within a given time interval.
Features
- uses persistent storage, so that failures are counted among independent script calls or pageviews
- storage drivers for filesystem, memcache and APCu
Install
The easiest way to install SoftFailer is by using composer:
$> composer require bitsbeats/softfailer
Usage
$storage = new Filesystem('/tmp/softfail.txt', 500); // hard fail if 3 or more "soft fails" occur within a 3600 second time window $sf = new SoftFailer($storage, 3, 3600); try { $sf->recordFailure(new DateTime()); } catch (HardFailLimitReachedException $e) { // a "hard fail" is triggered by throwing a "HardFailLimitReachedException" exception print "FAIL: {$e->getMessage()}\n"; $sf->clearFailPoints(); exit(1); }
See example.php for the full example.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2019-08-15