From 6e88cf3050db810a2a30b23144e2ac2a369e39f9 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 14 Mar 2022 14:54:47 +0000 Subject: [PATCH] Log and clear throttling cache every hour. (#220) --- src/main/java/me/kavin/piped/Main.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/me/kavin/piped/Main.java b/src/main/java/me/kavin/piped/Main.java index c4adbbe..98f738b 100644 --- a/src/main/java/me/kavin/piped/Main.java +++ b/src/main/java/me/kavin/piped/Main.java @@ -13,6 +13,7 @@ import org.hibernate.Transaction; import org.hibernate.query.Query; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.localization.Localization; +import org.schabi.newpipe.extractor.services.youtube.YoutubeThrottlingDecrypter; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; @@ -90,6 +91,18 @@ public class Main { } }, 0, TimeUnit.MINUTES.toMillis(60)); + new Timer().scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + try { + System.out.println(String.format("ThrottlingCache: %o entries", YoutubeThrottlingDecrypter.getCacheSize())); + YoutubeThrottlingDecrypter.clearCache(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }, 0, TimeUnit.MINUTES.toMillis(60)); + new ServerLauncher().launch(args); }