M
M
Myuji2021-03-06 03:20:21
Programming
Myuji, 2021-03-06 03:20:21

How to store dynamic data?

There is a certain number that is updated once a second, you need to store it for three days to display the graph. The average for the last minute is displayed and it is drawn to the chart. What is the best way to store such data? It is desirable that the data be loaded after restarting the program. Tell me how best to store such data when the new ones erase the old ones and data remains for a given amount of time. For now, I'll think about using an array for all seconds in three days and plotting on it.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Saboteur, 2021-03-06
@saboteur_kiev

Use time series Databases.
Or, to put it more simply, a database in which there is a timestamp -> value
And then build graphs for yourself.

V
valera89345, 2021-03-10
@valera89345

https://calculators.vip/en/2posmotret-fayl-bolshog...
This can help you, it helped me

J
Jourloy, 2021-03-06
@Jourloy

Write a number to the database, attach the date of receipt of this number
to the number Check numbers every second, if the current date differs from the one in the database, then delete it
Using the database is the only way to save variables after restarting the program

V
Vladimir Korotenko, 2021-03-06
@firedragon

Look, make a file with the following structure
Datetime time of the last record
Duration int number of records in the file
Pointer int pointer to the ring buffer
Next are the float * duration records
In your case there should be 3* 8600
Once per second you open the file and update the datetime pointer and the record by index pointer . The pointer grows monotonically when it becomes equal to the size it jumps to 0 in the general ring buffer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question