mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-03-18 11:02:09 +00:00
feat: support get license from jdmc
This commit is contained in:
@@ -296,6 +296,31 @@ def cached_method(ttl=20):
|
||||
return decorator
|
||||
|
||||
|
||||
def cached_method_to_redis(key, ttl, should_cache=None):
|
||||
from django.core.cache import cache
|
||||
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
# 尝试从缓存读取
|
||||
cached_result = cache.get(key)
|
||||
if cached_result is not None:
|
||||
return cached_result
|
||||
|
||||
# 执行函数
|
||||
result = func(*args, **kwargs)
|
||||
|
||||
# 判断是否缓存
|
||||
if should_cache is None or should_cache(result):
|
||||
cache.set(key, result, ttl)
|
||||
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
def bulk_handle(handler, batch_size=50, timeout=0.5):
|
||||
def decorator(func):
|
||||
from orgs.utils import get_current_org_id
|
||||
|
||||
@@ -750,6 +750,7 @@ class Config(dict):
|
||||
# JDMC
|
||||
'JDMC_ENABLED': False,
|
||||
'JDMC_SOCK_PATH': '',
|
||||
'JDMC_LICENSE_PUBLIC_KEY_PATH': '',
|
||||
}
|
||||
|
||||
old_config_map = {
|
||||
|
||||
@@ -281,3 +281,4 @@ if Path(VENDOR_TEMPLATES_DIR).is_dir():
|
||||
JDMC_ENABLED = CONFIG.JDMC_ENABLED
|
||||
JDMC_SOCK_PATH = CONFIG.JDMC_SOCK_PATH
|
||||
JDMC_BASE_URL = f"http+unix://{quote(JDMC_SOCK_PATH, safe='')}"
|
||||
JDMC_LICENSE_PUBLIC_KEY_PATH = CONFIG.JDMC_LICENSE_PUBLIC_KEY_PATH
|
||||
Reference in New Issue
Block a user