feat: use /threads module-provided cache

This commit is contained in:
Ayo Ayco 2024-05-19 22:08:06 +02:00
parent 1c79c58ac6
commit 2ce604e376
2 changed files with 5 additions and 9 deletions

2
cache/cache.py vendored
View file

@ -1,2 +0,0 @@
from flask_caching import Cache
cache = Cache()

12
web.py
View file

@ -1,23 +1,21 @@
from flask import Flask, send_from_directory from flask import Flask, send_from_directory
import sentry_sdk import sentry_sdk
import json import json
from cache.cache import cache
app = Flask(__name__) app = Flask(__name__)
app.config.from_file("config.json", load=json.load)
# /threads
try: try:
from threads.threads import threads from threads.threads import threads
app.register_blueprint(threads, url_prefix='/threads') app.register_blueprint(threads, url_prefix='/threads')
print(' * Threads blueprint registered') print(' * Threads blueprint registered')
from threads.cache import cache as thread_cache
print(' * Threads cache type: ' + app.config["CACHE_TYPE"])
thread_cache.init_app(app)
except ImportError: except ImportError:
print(' ! Threads blueprint not found') print(' ! Threads blueprint not found')
app.config.from_file("config.json", load=json.load)
# caching
print(' * Cache type: ' + app.config["CACHE_TYPE"])
cache.init_app(app)
# perf monitoring & error tracking # perf monitoring & error tracking
sentry_config = app.config["SENTRY"] sentry_config = app.config["SENTRY"]
print(' * Monitoring DSN: ' + sentry_config["dsn"]) print(' * Monitoring DSN: ' + sentry_config["dsn"])