feat: Clean cache periodically if thread is not available
This commit is contained in:
parent
53fa3e3fe2
commit
7e3e88cb74
1 changed files with 8 additions and 0 deletions
|
@ -9,6 +9,7 @@ import hashlib
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import shutil
|
import shutil
|
||||||
|
import random
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -215,6 +216,13 @@ def init_proxy_routes(app):
|
||||||
|
|
||||||
logger.debug(f"Proxy request for URL: {url}, filename: {filename}")
|
logger.debug(f"Proxy request for URL: {url}, filename: {filename}")
|
||||||
|
|
||||||
|
# Check if the cache cleanup thread is running
|
||||||
|
if cache_cleanup_thread is None:
|
||||||
|
# Use every 100th request to trigger cleanup
|
||||||
|
if random.randint(1, 100) == 1:
|
||||||
|
logger.debug("Triggering cache cleanup")
|
||||||
|
cache_cleanup(app)
|
||||||
|
|
||||||
if url is not None:
|
if url is not None:
|
||||||
if url.startswith("https://cdn.instructables.com/") or url.startswith(
|
if url.startswith("https://cdn.instructables.com/") or url.startswith(
|
||||||
"https://content.instructables.com/"
|
"https://content.instructables.com/"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue