mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: rsa_key cache setting (#3610)
This commit is contained in:
parent
2ead8b3ed2
commit
158bd2f43b
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue