From d110c75f497f406227cc995d0d0d9b549c05df60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?X=C3=A9fir=20Destiny?= Date: Wed, 11 Dec 2019 19:17:36 +0100 Subject: [PATCH] Useless cache --- app.py | 4 ++-- connectors.py | 17 +---------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/app.py b/app.py index 0c5fecc..2962a6e 100644 --- a/app.py +++ b/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 diff --git a/connectors.py b/connectors.py index 564ccc3..5799cb6 100644 --- a/connectors.py +++ b/connectors.py @@ -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()