From 6bbb4f577e637aef40e06954ec30e760510b8ca7 Mon Sep 17 00:00:00 2001 From: xuedinge <781408517@qq.com> Date: Thu, 18 Jan 2024 18:48:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=B7=A5=E5=85=B7=20->=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=20=E4=B8=8B=E7=9A=84=20'=E7=82=B9?= =?UTF-8?q?=E8=BF=99=E9=87=8C=E4=BB=8E=E7=8E=B0=E6=9C=89=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=88=9B=E5=BB=BA=E4=BB=A3=E7=A0=81'=20=20=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/view/systemTools/autoCode/index.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/src/view/systemTools/autoCode/index.vue b/web/src/view/systemTools/autoCode/index.vue index 07c3c0b7..56d24390 100644 --- a/web/src/view/systemTools/autoCode/index.vue +++ b/web/src/view/systemTools/autoCode/index.vue @@ -67,6 +67,7 @@ From f9c9af8261c9dda995a669d8be7739af9c9841a0 Mon Sep 17 00:00:00 2001 From: xuedinge <781408517@qq.com> Date: Sun, 31 Mar 2024 01:15:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0redis=E9=9B=86=E7=BE=A4?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/config.yaml | 10 +++++++++- server/config/redis.go | 8 +++++--- server/global/global.go | 2 +- server/initialize/redis.go | 20 +++++++++++++++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/server/config.yaml b/server/config.yaml index 7ba41f0b..7b1a73ab 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -19,9 +19,17 @@ zap: # redis configuration redis: - db: 0 + #是否使用redis集群模式 + useCluster: false + #使用集群模式addr和db默认无效 addr: 127.0.0.1:6379 password: "" + db: 0 + clusterAddrs: + - "172.21.0.3:7000" + - "172.21.0.4:7001" + - "172.21.0.2:7002" + # mongo configuration mongo: diff --git a/server/config/redis.go b/server/config/redis.go index 60dbb1ee..33c0ccbb 100644 --- a/server/config/redis.go +++ b/server/config/redis.go @@ -1,7 +1,9 @@ package config type Redis struct { - Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口 - Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码 - DB int `mapstructure:"db" json:"db" yaml:"db"` // redis的哪个数据库 + Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口 + Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码 + DB int `mapstructure:"db" json:"db" yaml:"db"` // 单实例模式下redis的哪个数据库 + UseCluster bool `mapstructure:"useCluster" json:"useCluster" yaml:"useCluster"` // 是否使用集群模式 + ClusterAddrs []string `mapstructure:"clusterAddrs" json:"clusterAddrs" yaml:"clusterAddrs"` // 集群模式下的节点地址列表 } diff --git a/server/global/global.go b/server/global/global.go index f7f93c2b..8310250e 100644 --- a/server/global/global.go +++ b/server/global/global.go @@ -21,7 +21,7 @@ import ( var ( GVA_DB *gorm.DB GVA_DBList map[string]*gorm.DB - GVA_REDIS *redis.Client + GVA_REDIS redis.UniversalClient GVA_MONGO *qmgo.QmgoClient GVA_CONFIG config.Server GVA_VP *viper.Viper diff --git a/server/initialize/redis.go b/server/initialize/redis.go index 044ca62d..41dfd76e 100644 --- a/server/initialize/redis.go +++ b/server/initialize/redis.go @@ -11,11 +11,21 @@ import ( func Redis() { redisCfg := global.GVA_CONFIG.Redis - client := redis.NewClient(&redis.Options{ - Addr: redisCfg.Addr, - Password: redisCfg.Password, // no password set - DB: redisCfg.DB, // use default DB - }) + var client redis.UniversalClient + // 使用集群模式 + if redisCfg.UseCluster { + client = redis.NewClusterClient(&redis.ClusterOptions{ + Addrs: redisCfg.ClusterAddrs, + Password: redisCfg.Password, + }) + } else { + // 使用单例模式 + client = redis.NewClient(&redis.Options{ + Addr: redisCfg.Addr, + Password: redisCfg.Password, + DB: redisCfg.DB, + }) + } pong, err := client.Ping(context.Background()).Result() if err != nil { global.GVA_LOG.Error("redis connect ping failed, err:", zap.Error(err)) From 9729bc00a084af33e3b1213ab2541f7c91aeff7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E9=A5=BF=E4=BA=86=E4=B8=8D=E5=85=BB?= =?UTF-8?q?=E5=96=B5?= <106448173+xue-ding-e@users.noreply.github.com> Date: Sun, 31 Mar 2024 03:58:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E6=8E=89=E4=BA=86=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E5=A2=9E=E5=8A=A0(=E5=B0=B1?= =?UTF-8?q?=E6=98=AF=E4=B9=8B=E5=89=8D=E8=AF=B4=E7=9A=84=E9=82=A3=E4=B8=AA?= =?UTF-8?q?=E6=A0=B7=E5=BC=8Fbug=E5=85=B6=E5=AE=9E=E4=B8=8D=E6=98=AFbug)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit style="width:194px" --- web/src/view/systemTools/autoCode/index.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/web/src/view/systemTools/autoCode/index.vue b/web/src/view/systemTools/autoCode/index.vue index 3b61f508..7a78b87a 100644 --- a/web/src/view/systemTools/autoCode/index.vue +++ b/web/src/view/systemTools/autoCode/index.vue @@ -66,7 +66,6 @@