mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-21 17:00:00 +00:00
Improve cache configuration (#564)
The Flask-Caching cache can now properly be configured from the config.py, and redis caching has experimentally been tested and confirmed to be working in theory. We also document that one may want to use CACHE_THRESHOLD to limit the maximum number of items in the simple cache.
This commit is contained in:
parent
d8e796f3e0
commit
80c9d580eb
|
@ -188,3 +188,20 @@ TRUSTED_MIN_UPLOADS = 10
|
|||
TRUSTED_MIN_DOWNLOADS = 10000
|
||||
# Number of days an applicant needs to wait before re-applying
|
||||
TRUSTED_REAPPLY_COOLDOWN = 90
|
||||
|
||||
###########
|
||||
## Cache ##
|
||||
###########
|
||||
|
||||
# Interesting types include "simple", "redis" and "uwsgi"
|
||||
# See https://pythonhosted.org/Flask-Caching/#configuring-flask-caching
|
||||
CACHE_TYPE = "simple"
|
||||
|
||||
# Maximum number of items the cache will store
|
||||
# Only applies to "simple" and "filesystem" cache types
|
||||
CACHE_THRESHOLD = 8192
|
||||
|
||||
# If you want to use redis, try this
|
||||
# CACHE_TYPE = "redis"
|
||||
# CACHE_REDIS_HOST = "127.0.0.1"
|
||||
# CACHE_KEY_PREFIX = "catcache_"
|
||||
|
|
|
@ -126,6 +126,6 @@ def create_app(config):
|
|||
app.config['DEFAULT_GRAVATAR_URL'] = url
|
||||
|
||||
# Cache
|
||||
cache.init_app(app)
|
||||
cache.init_app(app, config=app.config)
|
||||
|
||||
return app
|
||||
|
|
|
@ -10,7 +10,7 @@ from flask_sqlalchemy import BaseQuery, Pagination, SQLAlchemy
|
|||
assets = Environment()
|
||||
db = SQLAlchemy()
|
||||
toolbar = DebugToolbarExtension()
|
||||
cache = Cache(config={'CACHE_TYPE': 'simple'})
|
||||
cache = Cache()
|
||||
|
||||
|
||||
class LimitedPagination(Pagination):
|
||||
|
|
|
@ -47,6 +47,7 @@ SQLAlchemy-Utils==0.34.1
|
|||
statsd==3.3.0
|
||||
urllib3==1.25.3
|
||||
uWSGI==2.0.18
|
||||
redis==3.2.1
|
||||
webassets==0.12.1
|
||||
Werkzeug==0.15.5
|
||||
WTForms==2.2.1
|
||||
|
|
Loading…
Reference in a new issue