forked from ScoDoc/ScoDoc
Env. var specifying cache type
This commit is contained in:
parent
26ad2ba59b
commit
dcc06d6169
@ -43,11 +43,13 @@ mail = Mail()
|
|||||||
bootstrap = Bootstrap()
|
bootstrap = Bootstrap()
|
||||||
moment = Moment()
|
moment = Moment()
|
||||||
|
|
||||||
cache = Cache( # XXX TODO: configuration file
|
CACHE_TYPE = os.environ.get("CACHE_TYPE")
|
||||||
|
cache = Cache(
|
||||||
config={
|
config={
|
||||||
# see https://flask-caching.readthedocs.io/en/latest/index.html#configuring-flask-caching
|
# see https://flask-caching.readthedocs.io/en/latest/index.html#configuring-flask-caching
|
||||||
"CACHE_TYPE": "RedisCache",
|
"CACHE_TYPE": CACHE_TYPE or "RedisCache",
|
||||||
"CACHE_DEFAULT_TIMEOUT": 0, # by default, never expire
|
# by default, never expire:
|
||||||
|
"CACHE_DEFAULT_TIMEOUT": os.environ.get("CACHE_DEFAULT_TIMEOUT") or 0,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -187,6 +189,8 @@ def create_app(config_class=DevConfig):
|
|||||||
moment.init_app(app)
|
moment.init_app(app)
|
||||||
cache.init_app(app)
|
cache.init_app(app)
|
||||||
sco_cache.CACHE = cache
|
sco_cache.CACHE = cache
|
||||||
|
if CACHE_TYPE: # non default
|
||||||
|
app.logger.info(f"CACHE_TYPE={CACHE_TYPE}")
|
||||||
|
|
||||||
app.register_error_handler(ScoGenError, handle_sco_value_error)
|
app.register_error_handler(ScoGenError, handle_sco_value_error)
|
||||||
app.register_error_handler(ScoValueError, handle_sco_value_error)
|
app.register_error_handler(ScoValueError, handle_sco_value_error)
|
||||||
|
Loading…
Reference in New Issue
Block a user