diff --git a/apps/common/constants/cache_version.py b/apps/common/constants/cache_version.py index b4a5a7b6a..a4bbcae80 100644 --- a/apps/common/constants/cache_version.py +++ b/apps/common/constants/cache_version.py @@ -13,13 +13,13 @@ class Cache_Version(Enum): # 令牌 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 # 当前用户所有的角色 - 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): return self.value[0] diff --git a/apps/maxkb/conf.py b/apps/maxkb/conf.py index 1ca7c7f44..5b088967e 100644 --- a/apps/maxkb/conf.py +++ b/apps/maxkb/conf.py @@ -29,16 +29,6 @@ class Config(dict): # 语言 'LANGUAGE_CODE': 'zh-CN', "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: @@ -61,17 +51,12 @@ class Config(dict): } } - def get_cache_setting(self): + @staticmethod + def get_cache_setting(): return { 'default': { - 'BACKEND': 'django_redis.cache.RedisCache', - 'LOCATION': f'redis://{self.get("REDIS_HOST")}:{self.get("REDIS_PORT")}', - '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")} - }, + 'BACKEND': 'diskcache.DjangoCache', + 'LOCATION': f'{PROJECT_DIR}/data/cache' }, } diff --git a/apps/users/views/user.py b/apps/users/views/user.py index 18964ddd1..94e1a1796 100644 --- a/apps/users/views/user.py +++ b/apps/users/views/user.py @@ -13,7 +13,7 @@ from rest_framework.views import APIView from common.auth.authenticate import TokenAuth 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 users.api.user import UserProfileAPI, TestWorkspacePermissionUserApi from users.serializers.user import UserProfileSerializer diff --git a/pyproject.toml b/pyproject.toml index 152b37fe8..033d404d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,10 +11,10 @@ django = "5.2" drf-spectacular = { extras = ["sidecar"], version = "0.28.0" } django-redis = "5.4.0" 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" uuid-utils = "0.10.0" -diskcache = "5.6.3" +diskcache2 = "0.1.2" [build-system] requires = ["poetry-core"]