perf: 优化 redis (#8484)

* perf: 优化 redis

* perf: 优化 redis 时间

* perf: 优化时间

* perf: 修改 ssl

* perf: 修改 ssl

* perf: 修改 ssl name

* perf: 修改名称

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot
2022-06-28 17:23:20 +08:00
committed by GitHub
parent b33e376c90
commit c3c99cc5e8
8 changed files with 48 additions and 109 deletions

View File

@@ -1,11 +1,9 @@
import json
import threading
import redis
from redis import Redis
from django.conf import settings
from django.core.cache import cache
from jumpserver.const import CONFIG
from common.http import is_true
from common.db.utils import safe_db_connection
from common.utils import get_logger
@@ -13,18 +11,9 @@ logger = get_logger(__name__)
def get_redis_client(db=0):
params = {
'host': CONFIG.REDIS_HOST,
'port': CONFIG.REDIS_PORT,
'password': CONFIG.REDIS_PASSWORD,
'db': db,
"ssl": is_true(CONFIG.REDIS_USE_SSL),
'ssl_cert_reqs': getattr(settings, 'REDIS_SSL_REQUIRED'),
'ssl_keyfile': getattr(settings, 'REDIS_SSL_KEYFILE'),
'ssl_certfile': getattr(settings, 'REDIS_SSL_CERTFILE'),
'ssl_ca_certs': getattr(settings, 'REDIS_SSL_CA_CERTS'),
}
return Redis(**params)
client = cache.client.get_client()
assert isinstance(client, redis.Redis)
return client
class Subscription: