feat: provide app-wide cache

This commit is contained in:
Ayo Ayco 2024-05-19 21:01:19 +02:00
parent d44301ef14
commit 1c79c58ac6
2 changed files with 6 additions and 4 deletions

2
cache/cache.py vendored Normal file
View file

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

8
web.py
View file

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