mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-08 02:39:22 +00:00
perf(settings): 优化settings配置 (#5515)
* stash * perf: 优化 动态seting * perf(settings): 优化settings配置 * perf: 完成终端和安全setting * perf: 修改翻译 * perf: 去掉其他位置的DYNAMIC * perf: 还原回来原来的一些代码 * perf: 优化ldap * perf: 移除dynmic config * perf: 去掉debug消息 * perf: 优化 refresh 命名 Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
27
apps/common/utils/connection.py
Normal file
27
apps/common/utils/connection.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import redis
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def get_redis_client(db):
|
||||
rc = redis.StrictRedis(
|
||||
host=settings.REDIS_HOST,
|
||||
port=settings.REDIS_PORT,
|
||||
password=settings.REDIS_PASSWORD,
|
||||
db=db
|
||||
)
|
||||
return rc
|
||||
|
||||
|
||||
class RedisPubSub:
|
||||
def __init__(self, ch, db=10):
|
||||
self.ch = ch
|
||||
self.redis = get_redis_client(db)
|
||||
|
||||
def subscribe(self):
|
||||
ps = self.redis.pubsub()
|
||||
ps.subscribe(self.ch)
|
||||
return ps
|
||||
|
||||
def publish(self, data):
|
||||
self.redis.publish(self.ch, data)
|
||||
return True
|
Reference in New Issue
Block a user