From 175085823ba235f84951d75a2adad6b207d3842d Mon Sep 17 00:00:00 2001 From: JiebinHu <458249864@qq.com> Date: Sat, 2 Sep 2023 20:42:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=8E=BB=E6=8E=89=E6=97=A7=E7=9A=84redis?= =?UTF-8?q?=20=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/redisCli/redis.go | 20 -------------------- main.go | 30 ------------------------------ 2 files changed, 50 deletions(-) diff --git a/common/redisCli/redis.go b/common/redisCli/redis.go index c486ea9..a2b1e3d 100644 --- a/common/redisCli/redis.go +++ b/common/redisCli/redis.go @@ -9,7 +9,6 @@ import ( ) var RedisCluster *redis.Client -var RedisClient *redis.Client func init() { RedisCluster = redis.NewClient(&redis.Options{ @@ -26,21 +25,6 @@ func init() { } else { log.Println("redis db0 connection success - " + pong) } - - RedisClient = redis.NewClient(&redis.Options{ - Addr: config.GetConfigRedis().REDIS_HOST, - Password: config.GetConfigRedis().REDIS_PASSWORD, // no password set - DB: 0, // use default DB - PoolSize: 200, - MinIdleConns: 20, - }) - pong, err = RedisClient.Ping(context.Background()).Result() - if err != nil { - mylogrus.MyLog.Warn(err) - mylogrus.MyLog.Fatal("redis db0 connect fail") - } else { - log.Println("redis db0 connection success - " + pong) - } // log hook //RedisClient.AddHook(redisHook{}) } @@ -48,7 +32,3 @@ func init() { func GetRedisCluster() *redis.Client { return RedisCluster } - -func GetRedisClient() *redis.Client { - return RedisClient -} diff --git a/main.go b/main.go index 0fe9810..4491e33 100644 --- a/main.go +++ b/main.go @@ -28,9 +28,6 @@ func main() { go func() { deal() }() - go func() { - dealOld() // 临时处理 - }() } for i := 0; i < SEND_WORKER; i++ { go func() { @@ -92,33 +89,6 @@ func deal() { } } -func dealOld() { - for true { - //不需要加锁,注意,阻塞。 - strs, err := redisCli.GetRedisClient().BLPop(context.Background(), time.Second, micInfoChange).Result() - if err != nil { - if err != redis.Nil { - mylogrus.MyLog.Errorf("cron micChangeSys redisCli.GetRedis().BLPop err:+%v", err) - } - } - if len(strs) >= 2 { - content := strs[1] - //mylogrus.MyLog.Infof("cron micChangeSys content:%v", content) - micSystemMsg := MicSystemMsg{} - if err := json.Unmarshal([]byte(content), &micSystemMsg); err != nil { - mylogrus.MyLog.Errorf("cron micChangeSys Unmarshal err:%+v, content:%v", err, content) - } - sendChan <- GroupSystemMsg{ - MsgGroupUid: micSystemMsg.GroupUid, - MsgId: micSystemMsg.MsgId, - Source: micSystemMsg.Source, - Target: micSystemMsg.Target, - Content: micSystemMsg.Content, - } - } - } -} - //var limiter = rate.NewLimiter(2000, 2000) func send() { -- 2.22.0