You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iTi-Flask/iti/applications/extensions/cache.py

16 lines
595 B
Python

from flask_caching import Cache
cache_simple = Cache()
cache_redis = Cache()
def init_cache(app):
simpleConfig = app.config.get("CACHE_SIMPLE", None)
redisConfig = app.config.get("CACHE_REDIS", None)
if simpleConfig is not None and simpleConfig.get("ENABLED", False):
app.logger.info(f"初始化简单缓存: {simpleConfig}")
cache_simple.init_app(app, config=simpleConfig)
if redisConfig is not None and redisConfig.get("ENABLED", False):
app.logger.info(f"初始化 Redis 缓存: {redisConfig}")
cache_redis.init_app(app, config=redisConfig)