diff --git a/apps/common/event/__init__.py b/apps/common/event/__init__.py index 2b340e496..5af1b4ba2 100644 --- a/apps/common/event/__init__.py +++ b/apps/common/event/__init__.py @@ -6,9 +6,11 @@ @date:2023/11/10 10:43 @desc: """ +from django.core.cache import cache from django.utils.translation import gettext as _ from .listener_manage import * +from ..constants.cache_version import Cache_Version from ..db.sql_execute import update_execute update_document_status_sql = """ @@ -31,5 +33,7 @@ def run(): ) # 更新文档状态 update_execute(update_document_status_sql, []) + version, get_key = Cache_Version.SYSTEM.value + cache.delete(get_key(key='rsa_key'), version=version) finally: un_lock('event_init') diff --git a/apps/common/utils/rsa_util.py b/apps/common/utils/rsa_util.py index c47663fde..5631be50e 100644 --- a/apps/common/utils/rsa_util.py +++ b/apps/common/utils/rsa_util.py @@ -14,10 +14,11 @@ from Crypto.PublicKey import RSA from django.core import cache from django.db.models import QuerySet +from common.constants.cache_version import Cache_Version from system_manage.models import SystemSetting, SettingType lock = threading.Lock() -rsa_cache = cache.caches['default'] +rsa_cache = cache.cache cache_key = "rsa_key" # 对密钥加密的密码 secret_code = "mac_kb_password" @@ -45,7 +46,8 @@ def get_key_pair(): if rsa_value is not None: return rsa_value rsa_value = get_key_pair_by_sql() - rsa_cache.set(cache_key, rsa_value) + version, get_key = Cache_Version.SYSTEM.value + rsa_cache.set(get_key(key='rsa_key'), rsa_value, timeout=None, version=version) return rsa_value