Parcourir la source

chore: rename redis conn str (#222)

zijiren il y a 7 mois
Parent
commit
a4990efb4c

+ 1 - 1
README.md

@@ -133,7 +133,7 @@ ADMIN_KEY=your-admin-key        # Admin API key
 ```bash
 SQL_DSN=postgres://user:pass@host:5432/db    # Primary database
 LOG_SQL_DSN=postgres://user:pass@host:5432/log_db  # Log database (optional)
-REDIS_CONN_STRING=redis://localhost:6379     # Redis for caching
+REDIS=redis://localhost:6379     # Redis for caching
 ```
 
 #### **Feature Toggles**

+ 1 - 1
README.zh.md

@@ -133,7 +133,7 @@ ADMIN_KEY=your-admin-key        # 管理员 API 密钥
 ```bash
 SQL_DSN=postgres://user:pass@host:5432/db    # 主数据库
 LOG_SQL_DSN=postgres://user:pass@host:5432/log_db  # 日志数据库(可选)
-REDIS_CONN_STRING=redis://localhost:6379     # Redis 缓存
+REDIS=redis://localhost:6379     # Redis 缓存
 ```
 
 #### **功能开关**

+ 5 - 3
core/common/redis.go

@@ -5,6 +5,7 @@ import (
 	"os"
 	"time"
 
+	"github.com/labring/aiproxy/core/common/env"
 	"github.com/redis/go-redis/v9"
 	log "github.com/sirupsen/logrus"
 )
@@ -16,13 +17,14 @@ var (
 
 // InitRedisClient This function is called after init()
 func InitRedisClient() (err error) {
-	if os.Getenv("REDIS_CONN_STRING") == "" {
-		log.Info("REDIS_CONN_STRING not set, redis is not enabled")
+	redisConn := env.String("REDIS", os.Getenv("REDIS_CONN_STRING"))
+	if redisConn == "" {
+		log.Info("REDIS not set, redis is not enabled")
 		return nil
 	}
 	RedisEnabled = true
 	log.Info("redis is enabled")
-	opt, err := redis.ParseURL(os.Getenv("REDIS_CONN_STRING"))
+	opt, err := redis.ParseURL(redisConn)
 	if err != nil {
 		log.Fatal("failed to parse redis connection string: " + err.Error())
 	}

+ 1 - 1
core/deploy/Kubefile

@@ -11,7 +11,7 @@ ENV ADMIN_KEY=""
 ENV SEALOS_JWT_KEY="<sealos-jwt-key-placeholder>"
 ENV SQL_DSN="<sql-placeholder>"
 ENV LOG_SQL_DSN="<sql-log-placeholder>"
-ENV REDIS_CONN_STRING="<redis-placeholder>"
+ENV REDIS="<redis-placeholder>"
 
 ENV BALANCE_SEALOS_CHECK_REAL_NAME_ENABLE="false"
 ENV BALANCE_SEALOS_NO_REAL_NAME_USED_AMOUNT_LIMIT="1"

+ 1 - 1
core/deploy/manifests/aiproxy-config.yaml.tmpl

@@ -9,7 +9,7 @@ data:
   SEALOS_JWT_KEY: "{{ .SEALOS_JWT_KEY }}"
   SQL_DSN: "{{ .SQL_DSN }}"
   LOG_SQL_DSN: "{{ .LOG_SQL_DSN }}"
-  REDIS_CONN_STRING: "{{ .REDIS_CONN_STRING }}"
+  REDIS: "{{ .REDIS }}"
   BALANCE_SEALOS_CHECK_REAL_NAME_ENABLE: "{{ .BALANCE_SEALOS_CHECK_REAL_NAME_ENABLE }}"
   BALANCE_SEALOS_NO_REAL_NAME_USED_AMOUNT_LIMIT: "{{ .BALANCE_SEALOS_NO_REAL_NAME_USED_AMOUNT_LIMIT }}"
   SAVE_ALL_LOG_DETAIL: "{{ .SAVE_ALL_LOG_DETAIL }}"

+ 1 - 1
docker-compose.yaml

@@ -18,7 +18,7 @@ services:
       - LOG_DETAIL_STORAGE_HOURS=1
       - TZ=Asia/Shanghai
       - SQL_DSN=postgres://postgres:aiproxy@pgsql:5432/aiproxy
-      - REDIS_CONN_STRING=redis://redis
+      - REDIS=redis://redis
     healthcheck:
       test: ["CMD", "curl", "-f", "http://localhost:3000/api/status"]
       interval: 5s