feat:Use distcache
This commit is contained in:
parent
9108971fdc
commit
934871f5c6
@ -13,13 +13,13 @@ class Cache_Version(Enum):
|
|||||||
# 令牌
|
# 令牌
|
||||||
TOKEN = "TOKEN", lambda token: token
|
TOKEN = "TOKEN", lambda token: token
|
||||||
# 工作空间列表
|
# 工作空间列表
|
||||||
WORKSPACE_LIST = "WORKSPACE::LIST", lambda user_id: user_id
|
WORKSPACE_LIST = "WORKSPACE:LIST", lambda user_id: user_id
|
||||||
# 用户数据
|
# 用户数据
|
||||||
USER = "USER", lambda user_id: user_id
|
USER = "USER", lambda user_id: user_id
|
||||||
# 当前用户所有的角色
|
# 当前用户所有的角色
|
||||||
ROLE_LIST = "ROLE::LIST", lambda user_id: user_id
|
ROLE_LIST = "ROLE:LIST", lambda user_id: user_id
|
||||||
# 当前用户所有权限
|
# 当前用户所有权限
|
||||||
PERMISSION_LIST = "PERMISSION::LIST", lambda user_id: user_id
|
PERMISSION_LIST = "PERMISSION:LIST", lambda user_id: user_id
|
||||||
|
|
||||||
def get_version(self):
|
def get_version(self):
|
||||||
return self.value[0]
|
return self.value[0]
|
||||||
|
|||||||
@ -29,16 +29,6 @@ class Config(dict):
|
|||||||
# 语言
|
# 语言
|
||||||
'LANGUAGE_CODE': 'zh-CN',
|
'LANGUAGE_CODE': 'zh-CN',
|
||||||
"DEBUG": False,
|
"DEBUG": False,
|
||||||
# redis 目前先支持单机 哨兵的配置后期加上
|
|
||||||
'REDIS_HOST': '127.0.0.1',
|
|
||||||
# 端口
|
|
||||||
'REDIS_PORT': 6379,
|
|
||||||
# 密码
|
|
||||||
'REDIS_PASSWORD': 'Password123@postgres',
|
|
||||||
# 库
|
|
||||||
'REDIS_DB': 0,
|
|
||||||
# 最大连接数
|
|
||||||
'REDIS_MAX_CONNECTIONS': 100
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_debug(self) -> bool:
|
def get_debug(self) -> bool:
|
||||||
@ -61,17 +51,12 @@ class Config(dict):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_cache_setting(self):
|
@staticmethod
|
||||||
|
def get_cache_setting():
|
||||||
return {
|
return {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'django_redis.cache.RedisCache',
|
'BACKEND': 'diskcache.DjangoCache',
|
||||||
'LOCATION': f'redis://{self.get("REDIS_HOST")}:{self.get("REDIS_PORT")}',
|
'LOCATION': f'{PROJECT_DIR}/data/cache'
|
||||||
'OPTIONS': {
|
|
||||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
||||||
"DB": self.get("REDIS_DB"),
|
|
||||||
"PASSWORD": self.get("REDIS_PASSWORD"),
|
|
||||||
"CONNECTION_POOL_KWARGS": {"max_connections": self.get("REDIS_MAX_CONNECTIONS")}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ from rest_framework.views import APIView
|
|||||||
|
|
||||||
from common.auth.authenticate import TokenAuth
|
from common.auth.authenticate import TokenAuth
|
||||||
from common.auth.authentication import has_permissions
|
from common.auth.authentication import has_permissions
|
||||||
from common.constants.permission_constants import PermissionConstants
|
from common.constants.permission_constants import PermissionConstants, Permission, Group, Operate
|
||||||
from common.result import result
|
from common.result import result
|
||||||
from users.api.user import UserProfileAPI, TestWorkspacePermissionUserApi
|
from users.api.user import UserProfileAPI, TestWorkspacePermissionUserApi
|
||||||
from users.serializers.user import UserProfileSerializer
|
from users.serializers.user import UserProfileSerializer
|
||||||
|
|||||||
@ -11,10 +11,10 @@ django = "5.2"
|
|||||||
drf-spectacular = { extras = ["sidecar"], version = "0.28.0" }
|
drf-spectacular = { extras = ["sidecar"], version = "0.28.0" }
|
||||||
django-redis = "5.4.0"
|
django-redis = "5.4.0"
|
||||||
django-db-connection-pool = "1.2.5"
|
django-db-connection-pool = "1.2.5"
|
||||||
psycopg = {extras = ["binary"], version = "3.2.6"}
|
psycopg = { extras = ["binary"], version = "3.2.6" }
|
||||||
python-dotenv = "1.1.0"
|
python-dotenv = "1.1.0"
|
||||||
uuid-utils = "0.10.0"
|
uuid-utils = "0.10.0"
|
||||||
diskcache = "5.6.3"
|
diskcache2 = "0.1.2"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core"]
|
requires = ["poetry-core"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user