I have a Golang server (pet project) and each second I add 2879 bytes of data in database. At the moment I'm about a 1GB of data. I want to cleanup the database to avoid a moment when I'm run out of space and the ways I see to solve:
Create and run a time scheduled goroutine on the same process as a server. It starts when server starts.
Run a cronjob/systemd timed service with a
sqlite3command to cleanup the database.
The p.1 is like a clean way to solve the problem - explicit solution, you never miss that you need to take care about the data removing in another place.
The p.2 - I don't like it because it's implicit. If the service goes wrong - you will run out of the space.
---
I also consider variants to put the data in another table (like pending_removing)
I'm here to listen you opinions.
Thanks!