Useless cache
This commit is contained in:
parent
9c8bc00e8d
commit
d110c75f49
4
app.py
4
app.py
@ -4,7 +4,7 @@ from flask import redirect, render_template, request, url_for
|
||||
|
||||
from config import app, auth, db, ADMIN_USERNAME, ADMIN_PASSWORD, APP_PORT, IS_DEBUG
|
||||
from connectors import *
|
||||
from models import AnimeFolder, DeleteForm, SearchForm, EditForm
|
||||
from models import AnimeFolder, AnimeTitle, DeleteForm, SearchForm, EditForm
|
||||
|
||||
|
||||
@auth.verify_password
|
||||
@ -16,7 +16,7 @@ def verify_password(username, password):
|
||||
def boldify(name):
|
||||
query = request.args.get('q')
|
||||
name = Connector.boldify(name, query)
|
||||
for title in ConnectorCache.get_keywords():
|
||||
for title in AnimeTitle.query.all():
|
||||
if title.keyword is not query:
|
||||
name = Connector.boldify(name, title.keyword)
|
||||
return name
|
||||
|
@ -10,7 +10,7 @@ from sys import platform
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from models import AnimeTitle, AnimeLink
|
||||
from models import AnimeLink
|
||||
|
||||
|
||||
class ConnectorReturn(Enum):
|
||||
@ -26,9 +26,6 @@ class ConnectorLang(Enum):
|
||||
class Cache:
|
||||
CACHE_TIMEOUT = 60 * 60
|
||||
CACHE_DATA = {}
|
||||
CACHE_KEYWORDS = {
|
||||
'timeout': 0.0
|
||||
}
|
||||
|
||||
def cache_data(self, f):
|
||||
@wraps(f)
|
||||
@ -64,18 +61,6 @@ class Cache:
|
||||
|
||||
return wrapper
|
||||
|
||||
def get_keywords(self):
|
||||
timestamp = datetime.now().timestamp()
|
||||
if self.CACHE_KEYWORDS['timeout'] < timestamp:
|
||||
self.CACHE_KEYWORDS['data'] = AnimeTitle.query.all()
|
||||
self.CACHE_KEYWORDS['timeout'] = timestamp
|
||||
return self.CACHE_KEYWORDS['data']
|
||||
|
||||
def clear_keywords(self):
|
||||
self.CACHE_KEYWORDS = {
|
||||
'timeout': 0.0
|
||||
}
|
||||
|
||||
|
||||
ConnectorCache = Cache()
|
||||
|
||||
|
Reference in New Issue
Block a user