Be dynamic on cache timeout
This commit is contained in:
parent
d181062c72
commit
37bd6ad966
@ -20,6 +20,7 @@ IS_DEBUG = environ.get('FLASK_ENV', 'production') == 'development'
|
|||||||
ADMIN_USERNAME = environ.get('ADMIN_USERNAME', 'admin')
|
ADMIN_USERNAME = environ.get('ADMIN_USERNAME', 'admin')
|
||||||
ADMIN_PASSWORD = environ.get('ADMIN_PASSWORD', 'secret')
|
ADMIN_PASSWORD = environ.get('ADMIN_PASSWORD', 'secret')
|
||||||
APP_PORT = environ.get('FLASK_PORT', 5000)
|
APP_PORT = environ.get('FLASK_PORT', 5000)
|
||||||
|
CACHE_TIMEOUT = environ.get('CACHE_TIMEOUT', 60 * 60)
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = urandom(24).hex()
|
app.secret_key = urandom(24).hex()
|
||||||
|
@ -11,7 +11,7 @@ from urllib.parse import quote
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from config import IS_DEBUG
|
from config import IS_DEBUG, CACHE_TIMEOUT
|
||||||
from models import AnimeLink
|
from models import AnimeLink
|
||||||
|
|
||||||
|
|
||||||
@ -26,7 +26,6 @@ class ConnectorLang(Enum):
|
|||||||
|
|
||||||
|
|
||||||
class Cache:
|
class Cache:
|
||||||
CACHE_TIMEOUT = 60 * 60
|
|
||||||
CACHE_DATA = {}
|
CACHE_DATA = {}
|
||||||
|
|
||||||
def cache_data(self, f):
|
def cache_data(self, f):
|
||||||
@ -57,7 +56,7 @@ class Cache:
|
|||||||
if not connector.on_error:
|
if not connector.on_error:
|
||||||
self.CACHE_DATA[connector.__class__.__name__][f.__name__][connector.query][connector.page] = {
|
self.CACHE_DATA[connector.__class__.__name__][f.__name__][connector.query][connector.page] = {
|
||||||
'data': connector.data,
|
'data': connector.data,
|
||||||
'timeout': timestamp + self.CACHE_TIMEOUT,
|
'timeout': timestamp + CACHE_TIMEOUT,
|
||||||
'is_more': connector.is_more
|
'is_more': connector.is_more
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
Reference in New Issue
Block a user