File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,16 @@ class Config(dict):
2929 # 语言
3030 'LANGUAGE_CODE' : 'zh-CN' ,
3131 "DEBUG" : False ,
32+ # redis 目前先支持单机 哨兵的配置后期加上
33+ 'REDIS_HOST' : '127.0.0.1' ,
34+ # 端口
35+ 'REDIS_PORT' : 6379 ,
36+ # 密码
37+ 'REDIS_PASSWORD' : 'Password123@redis' ,
38+ # 库
39+ 'REDIS_DB' : 0 ,
40+ # 最大连接数
41+ 'REDIS_MAX_CONNECTIONS' : 100
3242 }
3343
3444 def get_debug (self ) -> bool :
@@ -52,11 +62,17 @@ def get_db_setting(self) -> dict:
5262 }
5363
5464 @staticmethod
55- def get_cache_setting ():
65+ def get_cache_setting (self ):
5666 return {
5767 'default' : {
58- 'BACKEND' : 'diskcache.DjangoCache' ,
59- 'LOCATION' : f'{ PROJECT_DIR } /data/cache'
68+ 'BACKEND' : 'django_redis.cache.RedisCache' ,
69+ 'LOCATION' : f'redis://{ self .get ("REDIS_HOST" )} :{ self .get ("REDIS_PORT" )} ' ,
70+ 'OPTIONS' : {
71+ 'CLIENT_CLASS' : 'django_redis.client.DefaultClient' ,
72+ "DB" : self .get ("REDIS_DB" ),
73+ "PASSWORD" : self .get ("REDIS_PASSWORD" ),
74+ "CONNECTION_POOL_KWARGS" : {"max_connections" : int (self .get ("REDIS_MAX_CONNECTIONS" ))}
75+ },
6076 },
6177 }
6278
You can’t perform that action at this time.
0 commit comments