From b5cc6373fbfe2db20bb14216242c2c56f9bfbafe Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 4 Nov 2024 13:56:01 -0500 Subject: Clean up cache every day Also add a slight delay when downloading images to prevent rate limiting from Scryfall. --- server_main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'server_main.cpp') diff --git a/server_main.cpp b/server_main.cpp index 8d2c4aa..34cb50c 100644 --- a/server_main.cpp +++ b/server_main.cpp @@ -36,7 +36,8 @@ class server { socket_.listen(port_); socket_.start_accept(); - asio::post(std::bind(&server::cleanup_thread, this)); + std::thread cleanup(std::bind(&server::cleanup_thread, this)); + cleanup.detach(); std::cout << "Listening on port " << port_ << "..." << std::endl; @@ -145,7 +146,9 @@ class server { void cleanup_thread() { for (;;) { - // sleep + std::this_thread::sleep_for(std::chrono::hours(24)); + + images_.cleanup(); } } -- cgit 1.4.1