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.
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