From cd40abbd58237055a51de5fbfb270863c4fb0f00 Mon Sep 17 00:00:00 2001 From: Henrique Lopes Date: Fri, 29 Sep 2017 22:35:33 -0300 Subject: [PATCH] adding a new option to define the cache type --- README.md | 4 ++++ flask_common.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 985d0ba..6b9b1b1 100644 --- a/README.md +++ b/README.md @@ -61,3 +61,7 @@ Flask-Common automatically configures [WhiteNoise](http://whitenoise.evans.io) t app.config['COMMON_POWERED_BY_DISABLED'] = 1 app.config['COMMON_PROCESSED_TIME_DISABLED'] = 1 +## Cache configures + By default *simple* is a default cache type. But can you change this options, following below steps. [Flask-Cache](https://pythonhosted.org/Flask-Cache/#configuring-flask-cache) + + app.config['COMMON_CACHE_TYPE'] = "simple" diff --git a/flask_common.py b/flask_common.py index b96d678..673b055 100644 --- a/flask_common.py +++ b/flask_common.py @@ -113,7 +113,7 @@ class Common(object): # Configure WhiteNoise. app.wsgi_app = WhiteNoise(app.wsgi_app, root=url_for('static', filename='')[1:]) - self.cache = Cache(app, config={'CACHE_TYPE': 'simple'}) + self.cache = Cache(app, config={'CACHE_TYPE': app.config.get("COMMON_CACHE_TYPE", 'simple')}) @app.before_request def before_request_callback():