use redis
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
import redis
|
||||
|
||||
|
||||
class BaseConfig:
|
||||
|
||||
SYSTEM_NAME = os.getenv('SYSTEM_NAME', 'Pear Admin')
|
||||
# 主题面板的链接列表配置
|
||||
SYSTEM_PANEL_LINKS = [
|
||||
@@ -43,6 +44,13 @@ class BaseConfig:
|
||||
MYSQL_PORT = int(os.getenv('MYSQL_PORT') or 3306)
|
||||
MYSQL_DATABASE = os.getenv('MYSQL_DATABASE') or "PearAdminFlask"
|
||||
|
||||
SESSION_USE_SIGNER = True
|
||||
# 指明保存到redis中
|
||||
SESSION_TYPE = "redis"
|
||||
SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=4)
|
||||
# session的有效期,单位:秒
|
||||
PERMANENT_SESSION_LIFETIME = 7200
|
||||
|
||||
# mysql 数据库的配置信息
|
||||
SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{MYSQL_USERNAME}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DATABASE}"
|
||||
# 默认日志等级
|
||||
|
||||
@@ -9,6 +9,7 @@ from .init_mail import init_mail
|
||||
from .init_apscheduler import init_scheduler
|
||||
from .init_upload import init_upload
|
||||
from .init_dotenv import init_dotenv
|
||||
from .init_session import session
|
||||
|
||||
|
||||
def init_plugs(app: Flask) -> None:
|
||||
@@ -21,3 +22,4 @@ def init_plugs(app: Flask) -> None:
|
||||
init_scheduler(app)
|
||||
init_upload(app)
|
||||
init_dotenv()
|
||||
session.init_app(app)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
from flask_session import Session
|
||||
|
||||
session = Session()
|
||||
Reference in New Issue
Block a user