Log and clear throttling cache every hour.

This commit is contained in:
Kavin 2022-03-14 14:52:30 +00:00
parent d284943c14
commit 22cf53404d
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD

View file

@ -13,6 +13,7 @@ import org.hibernate.Transaction;
import org.hibernate.query.Query; import org.hibernate.query.Query;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.localization.Localization; import org.schabi.newpipe.extractor.localization.Localization;
import org.schabi.newpipe.extractor.services.youtube.YoutubeThrottlingDecrypter;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
@ -90,6 +91,18 @@ public class Main {
} }
}, 0, TimeUnit.MINUTES.toMillis(60)); }, 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); new ServerLauncher().launch(args);
} }