Home > Backend Development > PHP Tutorial > How to count the number of messages per hour on a message board that uses redis to store message content?

How to count the number of messages per hour on a message board that uses redis to store message content?

WBOY
Release: 2016-08-18 09:16:08
Original
1301 people have browsed it

My idea is to store each message in a hash, and then use the add_timestamp field to record the timestamp of the message, but now I don’t know how to perform a group by operation on the timestamp field in the hash by hour in redis, or what else Any other better way?
I don’t plan to save them in mysql because these messages are short in content but extremely high in volume and frequency. I see that websites like BAT have work order processing and statistics systems such as the number of work orders submitted per hour or Taobao's group purchase statistics system, which is used to count the sales of products with extremely high sales per second in different time periods. I Their needs are probably similar to them.

Reply content:

My idea is to store each message in a hash, and then use the add_timestamp field to record the timestamp of the message, but now I don’t know how to perform a group by operation on the timestamp field in the hash by hour in redis, or what else Any other better way?
I don’t plan to save them in mysql, because these messages are short in content but extremely high in volume and frequency. I see that websites like BAT have work order processing and statistics systems such as the number of work orders submitted per hour or Taobao's group purchase statistics system, which is used to count the sales of products with extremely high sales per second in different time periods. I Their needs are probably similar to them.

It can be stored in redis, but it is recommended to consider the capacity issue. After all, redis only uses limited memory capacity. You can consider batch synchronization to nosql, such as mongodb, hbase, etc., which are relatively new to read redis and have frequent access. Old messages read nosql and have fewer visits

As for the number of messages per hour, just use the redis counter to count, the key is 16.8.13-1, which means the first hour of August 13th, and the value is the number of messages

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template