承接 bigtallbill/php-mongo-graph-model 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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)
    }
}

统计信息

  • 总下载量: 750
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-05-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固