Giter VIP home page Giter VIP logo

byter-epad's Introduction

byter-epad

数据存储设计

redis

上报数据的两个维度: 时间、计数

  • 时间

    • 每月
    • 每7天
    • 每天
    • 每小时
    • 每10分钟
  • 计数

    • 原始数据
    • 增量数据

原始数据: 上报上来的计数是901, 就存901

增量数据: 当前上报计数 - 上一次上报计数. 本质是"一个时间段"内的计数增量, 需要定义时间段的长度, 比如10min. 注意: 上一次上报计数可能是"一个时间段"之前的, 这种情况需要将上一次上报计数看作0

数据结构

  1. 每月数据
<bid>_<mac>_<YYYYMM>: {
    raw: <每月最后一条原始计数>,
    inc: <每月增量>
}
  1. 每7天数据

实时聚合7天数据, (每天只需要算一次)

  1. 每天数据
实时数据
<bid>_<mac>_<YYYYMMDD>: {
    raw_<hour>_<minute>: <每分钟最后一条原始计数>, // 实时创建、更新
}

统计数据
<bid>_<mac>_<YYYYMMDD>_stat: {
    last_at: <每天第一条原始计数时间>, // 定时任务
    first_at: <每天最后一条原始计数时间>, // 定时任务

    raw: <每天最后一条原始计数>, // 定时任务?
    inc: <每天增量>, // 定时任务?

    raw_1h_<hour>: <每小时最后一条原始计数>, // 定时任务?
    inc_1h_<hour>: <每小时增量>,  // 定时任务? hour取值为[0, 23]
    
    inc_10m_<hour>_<minute>: <每10分钟增量>, // 定时任务? minute取值为10, 20, 30, 40, 50, 60, 为每一段时间的末尾时间点
}

每次收到MQTT消息进行的处理

byter-epad's People

Contributors

erhao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.