serial to tcp with buffer


I have serial-device connected to rpi3. It sends 100 characters twice in second to rpi.
I resend these with tcpsocket to client (mac or win) in local network (wifi). There is live chart in client.
Now I need to build buffer in rpi, so if client drops connection, it gets all packets when it reconnects.
One session can be up to one hour so there is some data.
I’m thinking sqlite database as buffer on rpi. So I read from serial, save to sqlite, and then send from sqlite to tcpsocket.
Or would it be faster if I install mysql-server to rpi and use it as buffer? Client can read data directly from mysql and I can skip tcpsocket?
Or any other suggestion are welcome…



How about appending the data to an array and then using a timer to remove them and send to client if connection is active? You would lose your buffer data if the app quit though.

Why do you think it can be faster with a mySQL? SQLite, for task like this one is faster.

And if you don’t care to loose your buffer when the app quit, you can use an in memory SQLite db (that’s really fast)
(If you don’t want to loose data when the app quits, you could save your memory db to disk and reload at startup)