diff --git a/config.py b/config.py index 71a4adf..7b154d7 100644 --- a/config.py +++ b/config.py @@ -20,6 +20,7 @@ IS_DEBUG = environ.get('FLASK_ENV', 'production') == 'development' ADMIN_USERNAME = environ.get('ADMIN_USERNAME', 'admin') ADMIN_PASSWORD = environ.get('ADMIN_PASSWORD', 'secret') APP_PORT = environ.get('FLASK_PORT', 5000) +CACHE_TIMEOUT = environ.get('CACHE_TIMEOUT', 60 * 60) app = Flask(__name__) app.secret_key = urandom(24).hex() diff --git a/connectors.py b/connectors.py index c54ae60..0314372 100644 --- a/connectors.py +++ b/connectors.py @@ -11,7 +11,7 @@ from urllib.parse import quote import requests from bs4 import BeautifulSoup -from config import IS_DEBUG +from config import IS_DEBUG, CACHE_TIMEOUT from models import AnimeLink @@ -26,7 +26,6 @@ class ConnectorLang(Enum): class Cache: - CACHE_TIMEOUT = 60 * 60 CACHE_DATA = {} def cache_data(self, f): @@ -57,7 +56,7 @@ class Cache: if not connector.on_error: self.CACHE_DATA[connector.__class__.__name__][f.__name__][connector.query][connector.page] = { 'data': connector.data, - 'timeout': timestamp + self.CACHE_TIMEOUT, + 'timeout': timestamp + CACHE_TIMEOUT, 'is_more': connector.is_more } return ret