Skip to content

Commit 158bd2f

Browse files
authored
fix: rsa_key cache setting (#3610)
1 parent 2ead8b3 commit 158bd2f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

apps/common/event/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
@date:2023/11/10 10:43
77
@desc:
88
"""
9+
from django.core.cache import cache
910
from django.utils.translation import gettext as _
1011

1112
from .listener_manage import *
13+
from ..constants.cache_version import Cache_Version
1214
from ..db.sql_execute import update_execute
1315

1416
update_document_status_sql = """
@@ -31,5 +33,7 @@ def run():
3133
)
3234
# 更新文档状态
3335
update_execute(update_document_status_sql, [])
36+
version, get_key = Cache_Version.SYSTEM.value
37+
cache.delete(get_key(key='rsa_key'), version=version)
3438
finally:
3539
un_lock('event_init')

apps/common/utils/rsa_util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
from django.core import cache
1515
from django.db.models import QuerySet
1616

17+
from common.constants.cache_version import Cache_Version
1718
from system_manage.models import SystemSetting, SettingType
1819

1920
lock = threading.Lock()
20-
rsa_cache = cache.caches['default']
21+
rsa_cache = cache.cache
2122
cache_key = "rsa_key"
2223
# 对密钥加密的密码
2324
secret_code = "mac_kb_password"
@@ -45,7 +46,8 @@ def get_key_pair():
4546
if rsa_value is not None:
4647
return rsa_value
4748
rsa_value = get_key_pair_by_sql()
48-
rsa_cache.set(cache_key, rsa_value)
49+
version, get_key = Cache_Version.SYSTEM.value
50+
rsa_cache.set(get_key(key='rsa_key'), rsa_value, timeout=None, version=version)
4951
return rsa_value
5052

5153

0 commit comments

Comments
 (0)