From 388310c804f05c9126d8bb750b996373b9a47a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Thu, 11 Aug 2022 10:08:06 +0800 Subject: [PATCH] - update redis --- const.go | 2 +- go.mod | 1 - go.sum | 2 -- redis.go | 2 +- redis_6.go | 47 --------------------------------------- redis_7.go | 47 --------------------------------------- redis_get.go | 2 +- redis_hash_operation.go | 2 +- redis_list_operation.go | 2 +- redis_simple_operation.go | 2 +- redis_string_operation.go | 2 +- 11 files changed, 7 insertions(+), 104 deletions(-) delete mode 100644 redis_6.go delete mode 100644 redis_7.go diff --git a/const.go b/const.go index b036f52..20d0f6a 100644 --- a/const.go +++ b/const.go @@ -1,3 +1,3 @@ package dorm -const Version = "1.0.13" +const Version = "1.0.14" diff --git a/go.mod b/go.mod index abf82be..1b8d8a2 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.19 require ( github.com/basgys/goxml2json v1.1.0 - github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redis/v9 v9.0.0-beta.1 github.com/go-sql-driver/mysql v1.6.0 github.com/kamva/mgm/v3 v3.4.1 diff --git a/go.sum b/go.sum index 23762b6..5d404ae 100644 --- a/go.sum +++ b/go.sum @@ -89,8 +89,6 @@ github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD87 github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= -github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-redis/redis/v9 v9.0.0-beta.1 h1:oW3jlPic5HhGUbYMH0lidnP+72BgsT+lCwlVud6o2Mc= github.com/go-redis/redis/v9 v9.0.0-beta.1/go.mod h1:6gNX1bXdwkpEG0M/hEBNK/Fp8zdyCkjwwKc6vBbfCDI= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= diff --git a/redis.go b/redis.go index 605df1c..96cc95f 100644 --- a/redis.go +++ b/redis.go @@ -4,7 +4,7 @@ import ( "context" "errors" "fmt" - "github.com/go-redis/redis/v8" + "github.com/go-redis/redis/v9" "time" ) diff --git a/redis_6.go b/redis_6.go deleted file mode 100644 index e72b0d0..0000000 --- a/redis_6.go +++ /dev/null @@ -1,47 +0,0 @@ -package dorm - -import ( - "context" - "errors" - "fmt" - "github.com/go-redis/redis/v8" - "time" -) - -// RedisClient6 -// https://redis.uptrace.dev/ -type RedisClient6 struct { - Db *redis.Client // 驱动 - config *ConfigRedisClient // 配置 -} - -// NewRedisClient6 Redis 6 -func NewRedisClient6(config *ConfigRedisClient) (*RedisClient6, error) { - - c := &RedisClient6{} - c.config = config - if c.config.PoolSize == 0 { - c.config.PoolSize = 100 - } - - c.Db = redis.NewClient(&redis.Options{ - Addr: c.config.Addr, // 地址 - Password: c.config.Password, // 密码 - DB: c.config.DB, // 数据库 - PoolSize: c.config.PoolSize, // 连接池大小 - }) - - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - - _, err := c.Db.Ping(ctx).Result() - if err != nil { - return nil, errors.New(fmt.Sprintf("连接失败:%v", err)) - } - - return c, nil -} - -func (c *RedisClient6) GetDb() *redis.Client { - return c.Db -} diff --git a/redis_7.go b/redis_7.go deleted file mode 100644 index f4893f6..0000000 --- a/redis_7.go +++ /dev/null @@ -1,47 +0,0 @@ -package dorm - -import ( - "context" - "errors" - "fmt" - "github.com/go-redis/redis/v9" - "time" -) - -// RedisClient7 -// https://redis.uptrace.dev/ -type RedisClient7 struct { - Db *redis.Client // 驱动 - config *ConfigRedisClient // 配置 -} - -// NewRedisClient7 Redis 7 -func NewRedisClient7(config *ConfigRedisClient) (*RedisClient7, error) { - - c := &RedisClient7{} - c.config = config - if c.config.PoolSize == 0 { - c.config.PoolSize = 100 - } - - c.Db = redis.NewClient(&redis.Options{ - Addr: c.config.Addr, // 地址 - Password: c.config.Password, // 密码 - DB: c.config.DB, // 数据库 - PoolSize: c.config.PoolSize, // 连接池大小 - }) - - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - - _, err := c.Db.Ping(ctx).Result() - if err != nil { - return nil, errors.New(fmt.Sprintf("连接失败:%v", err)) - } - - return c, nil -} - -func (c *RedisClient7) GetDb() *redis.Client { - return c.Db -} diff --git a/redis_get.go b/redis_get.go index 0761b17..6eb83ae 100644 --- a/redis_get.go +++ b/redis_get.go @@ -1,6 +1,6 @@ package dorm -import "github.com/go-redis/redis/v8" +import "github.com/go-redis/redis/v9" // GetDb 获取驱动 func (c *RedisClient) GetDb() *redis.Client { diff --git a/redis_hash_operation.go b/redis_hash_operation.go index ca8c2a2..6e29e1d 100644 --- a/redis_hash_operation.go +++ b/redis_hash_operation.go @@ -2,7 +2,7 @@ package dorm import ( "context" - "github.com/go-redis/redis/v8" + "github.com/go-redis/redis/v9" ) type HashOperation struct { diff --git a/redis_list_operation.go b/redis_list_operation.go index 7cf7921..b231ce2 100644 --- a/redis_list_operation.go +++ b/redis_list_operation.go @@ -2,7 +2,7 @@ package dorm import ( "context" - "github.com/go-redis/redis/v8" + "github.com/go-redis/redis/v9" ) type ListOperation struct { diff --git a/redis_simple_operation.go b/redis_simple_operation.go index 3496d84..c326e3a 100644 --- a/redis_simple_operation.go +++ b/redis_simple_operation.go @@ -2,7 +2,7 @@ package dorm import ( "context" - "github.com/go-redis/redis/v8" + "github.com/go-redis/redis/v9" "time" ) diff --git a/redis_string_operation.go b/redis_string_operation.go index 439f5e5..90d1dd8 100644 --- a/redis_string_operation.go +++ b/redis_string_operation.go @@ -2,7 +2,7 @@ package dorm import ( "context" - "github.com/go-redis/redis/v8" + "github.com/go-redis/redis/v9" "time" )