feat: support get license from jdmc

This commit is contained in:
Bai
2026-03-06 18:46:04 +08:00
parent 793c78fadf
commit 3bf495a02a
3 changed files with 27 additions and 0 deletions

View File

@@ -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

View File

@@ -750,6 +750,7 @@ class Config(dict):
# JDMC
'JDMC_ENABLED': False,
'JDMC_SOCK_PATH': '',
'JDMC_LICENSE_PUBLIC_KEY_PATH': '',
}
old_config_map = {

View File

@@ -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