ganglio/memoizer
Composer 安装命令:
composer require ganglio/memoizer
包简介
Simple PHP Memoizer class
关键字:
README 文档
README
Simple PHP Memoizer class
The class allow to encapsulate any callable so that, during the first call (with a given set of arguments), the callable is executed and the return values are stored. At every successive call (with the same set of arguments) the stored value is used instead of invoking the callable again.
Examples
This is a dumb example with a time variant call just to demonstate the way the memoized function works. If your callable has that kind of behaviour memoizing it is probably not a good idea :D
$myFunc = function ($a) { return $a * mt_rand(); } $myMemoizedFunc = new Memoizer($myFunc); echo "Returns: " . $myMemoizedFunc(3) . "\n"; echo "Returns the same value: " . $myMemoizedFunc(3) . "\n";
A time consuming callable can be made more efficient storing the return value for later invokation.
$mySlowFunc = function ($a) { sleep(5); return $a * mt_rand(); } $myMemoizedSlowFunc = new Memoizer($mySlowFunc); $st = time(); echo "Returns: " . $myMemoizedSlowFunc(3) . " in: " . (time() - $st); $st = time(); echo "Returns the same value: " . $myMemoizedSlowFunc(3) . " in basically 0 time: " . (time() - $st);
ganglio/memoizer 适用场景与选型建议
ganglio/memoizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「memoize」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ganglio/memoizer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ganglio/memoizer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ganglio/memoizer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Non-standard PHP library (NSPL) - functional primitives toolbox and more
A small helper for memoizing.
PSR-6/PSR-16 cache layer with local, distributed, and cloud adapters.
Memoize your expensive computed values to use in different components per each request.
A PHP library providing memoization functionality to cache the results of expensive function calls and return the cached result when the same inputs occur again
A simple memoization function
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-27