Be dynamic on cache timeout

This commit is contained in:
Michel Roux 2019-12-23 10:34:38 +01:00
parent d181062c72
commit 37bd6ad966
2 changed files with 3 additions and 3 deletions

View File

@ -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()

View File

@ -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