bigtallbill/php-mongo-graph-model
Composer 安装命令:
composer require bigtallbill/php-mongo-graph-model
包简介
A data model for storing incremental data for graphs
README 文档
README
A small library that helps store graph-type (incremental stats) in mongo database using doctrine ODM
Installation
Add this to your composer.json
"require": {
"bigtallbill/php-mongo-graph-model": "dev-master"
}
Usage
// instantiate a new instance providing the doctrine DocumentManager instance
$gm = new GraphManager($dm);
$gm->setGranularity(GraphManager::MINUTE);
$gm->setWindow(GraphManager::HOUR);
// create a random statistic to store. These are instances of ParsedStat
// and can be created manually if required
$stat = $gm->parseSimpleKeyValue('system_stats', 'cpu', rand(25, 50));
// finally run an upsert using doctrine to create or update the stat
$gm->insertStat($stat);
How this model looks
Using a granularity of Hours and a window of Days:
{
"_id" : ObjectId("5560b3b7919124c4e03710fd"),
"date" : ISODate("2015-05-23T00:00:00.000Z"),
"granularity" : NumberLong(3600),
"group" : "system_stats",
"key" : "mem",
"window" : NumberLong(86400),
"window_human" : "Day",
"granularity_human" : "Hour",
"segments" : {
"1432400400" : NumberLong(108588),
"1432404000" : NumberLong(119624)
}
}
Under the segments key is where each segment of granularity is stored (in our case the top of the current hour). The date is locked to the top of the current window (in our case the current day)
Here is another example with a granularity of minutes and a window of hours:
{
"_id" : ObjectId("5560c023919124c4e0371102"),
"date" : ISODate("2015-05-23T18:00:00.000Z"),
"granularity" : NumberLong(60),
"group" : "system_stats",
"key" : "processes",
"window" : NumberLong(3600),
"window_human" : "Hour",
"granularity_human" : "Minute",
"segments" : {
"1432404000" : NumberLong(59041),
"1432404060" : NumberLong(41138),
"1432404120" : NumberLong(62544),
"1432404180" : NumberLong(59392),
"1432404240" : NumberLong(22948),
"1432404300" : NumberLong(58825),
"1432404360" : NumberLong(31936),
"1432404420" : NumberLong(17407),
"1432404480" : NumberLong(30097),
"1432404540" : NumberLong(54094),
"1432404600" : NumberLong(34739),
"1432404660" : NumberLong(34164),
"1432404720" : NumberLong(34571),
"1432404780" : NumberLong(28592)
}
}
bigtallbill/php-mongo-graph-model 适用场景与选型建议
bigtallbill/php-mongo-graph-model 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 750 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 05 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bigtallbill/php-mongo-graph-model 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bigtallbill/php-mongo-graph-model 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 750
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-05-23