Skip to content

Commit

Permalink
优化redis
Browse files Browse the repository at this point in the history
  • Loading branch information
palp1tate committed Sep 1, 2023
1 parent f5261e5 commit 0fbb6d6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/comment/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"ByteRhythm/app/comment/service"
"ByteRhythm/config"
"ByteRhythm/idl/comment/commentPb"

"github.com/go-micro/plugins/v4/registry/etcd"

"fmt"
Expand All @@ -18,6 +19,9 @@ func main() {
dao.InitMySQL()
dao.InitRedis()

defer dao.RedisNo1Client.Close()
defer dao.RedisNo2Client.Close()

// etcd注册件
etcdReg := etcd.NewRegistry(
registry.Addrs(fmt.Sprintf("%s:%s", config.EtcdHost, config.EtcdPort)),
Expand Down
5 changes: 4 additions & 1 deletion app/favorite/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
"ByteRhythm/mq"
"context"
"fmt"
"os"

"github.com/go-micro/plugins/v4/registry/etcd"
ratelimit "github.com/go-micro/plugins/v4/wrapper/ratelimiter/uber"
"github.com/go-micro/plugins/v4/wrapper/select/roundrobin"
"github.com/go-micro/plugins/v4/wrapper/trace/opentracing"
"os"

"go-micro.dev/v4"
"go-micro.dev/v4/registry"
Expand All @@ -27,6 +28,8 @@ func main() {
mq.InitRabbitMQ()
loadingScript()

defer dao.RedisClient.Close()

// etcd注册件
etcdReg := etcd.NewRegistry(
registry.Addrs(fmt.Sprintf("%s:%s", config.EtcdHost, config.EtcdPort)),
Expand Down
5 changes: 4 additions & 1 deletion app/message/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"ByteRhythm/config"
"ByteRhythm/idl/message/messagePb"
"fmt"
"os"

"github.com/go-micro/plugins/v4/registry/etcd"
ratelimit "github.com/go-micro/plugins/v4/wrapper/ratelimiter/uber"
"github.com/go-micro/plugins/v4/wrapper/select/roundrobin"
"github.com/go-micro/plugins/v4/wrapper/trace/opentracing"
"os"

"go-micro.dev/v4"
"go-micro.dev/v4/registry"
Expand All @@ -22,6 +23,8 @@ func main() {
dao.InitMySQL()
dao.InitRedis()

defer dao.RedisClient.Close()

// etcd注册件
etcdReg := etcd.NewRegistry(
registry.Addrs(fmt.Sprintf("%s:%s", config.EtcdHost, config.EtcdPort)),
Expand Down
5 changes: 4 additions & 1 deletion app/relation/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"ByteRhythm/config"
"ByteRhythm/idl/relation/relationPb"
"fmt"
"os"

"github.com/go-micro/plugins/v4/registry/etcd"
ratelimit "github.com/go-micro/plugins/v4/wrapper/ratelimiter/uber"
"github.com/go-micro/plugins/v4/wrapper/select/roundrobin"
"github.com/go-micro/plugins/v4/wrapper/trace/opentracing"
"os"

"go-micro.dev/v4"
"go-micro.dev/v4/registry"
Expand All @@ -22,6 +23,8 @@ func main() {
dao.InitMySQL()
dao.InitRedis()

defer dao.RedisClient.Close()

// etcd注册件
etcdReg := etcd.NewRegistry(
registry.Addrs(fmt.Sprintf("%s:%s", config.EtcdHost, config.EtcdPort)),
Expand Down
3 changes: 3 additions & 0 deletions app/video/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func main() {
dao.InitRedis()
mq.InitRabbitMQ()
loadingScript()

defer dao.RedisClient.Close()

// etcd注册件
etcdReg := etcd.NewRegistry(
registry.Addrs(fmt.Sprintf("%s:%s", config.EtcdHost, config.EtcdPort)),
Expand Down
2 changes: 1 addition & 1 deletion config/config.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Gin]
AppMode = debug
HttpHost = 0.0.0.0
HttpPort = 4000
HttpPort = 8080

[MySQL]
DBHost = 127.0.0.1
Expand Down

0 comments on commit 0fbb6d6

Please sign in to comment.