Is it suitable to implement statistical functions with redis?

at present, there is a need to count the data of some dailies and show them with echarts. Because it may involve calculating the sum of months or years according to the day, I hope to find a way to do the calculation instead of mysql. The first thing that comes to mind is redis, but I only found the method of calculating the quantity, but did not find the method of calculating the sum of the specific values in the key. So can redis do such a thing? If not, is there any good solution?

in the past, this type of statistical requirements were calculated directly through mysql, but this demand is too large for mysql to handle.

Dec.24,2021

influxdb


1. One of the main functions of redis is to do caching, which solves the problem of high concurrency.
2. If the problem is that the amount of data is huge and the mysql processing time is long, you can only optimize mysql, which has nothing to do with redis.
3. If you hit the cache to redis after processing mysql data, this is actually possible. For example, the sum of daily, monthly or annual data is saved in redis and the data is fetched from redis, but the problem that may arise is that when the cache policy fails, the request will be called into mysql, so that the request will actually slow down.
4. Another solution is to create a statistical table, which is dedicated to statistical data. Run scripts to update the data regularly, and the data is taken from this statistical table. In this way, in fact, data requests will be faster, the principle and redis are not much.
5. Redis is a database in the form of key:value. For value, redis does not have any calculation method, because you cannot determine the value type of value. Generally, the award value is taken out by itself and calculated manually.

Menu