Let's assume that I am continuously receiving big amount of data. For example, this millisecond I get 100 numbers, next millisecond I get another 500 numbers, after that I might get nothing for a several milliseconds and then again get some numbers in the next millisecond. Also assume that this process lasts for weeks. However, I don't really need to save old data in memory. What I really need is to remember data received in the last 5 minutes. That is, all I want is to be able to present data for last 5 minutes whenever I am asked to.
Do you have any ideas on how to realize this? What kind of data structure would help in such a situation and how should I use it? All I could imagine was saving with every piece of data the moment of time when it was received, storing everything in a queue and constantly deleting element from queue's head if its time shows that it was received more than 5 minutes ago. I hope there is a more elegant/efficient solution.
Thank you.