|
@@ -23,9 +23,9 @@ func InitRedisCluster(addrs []string) {
|
|
|
|
|
|
//set
|
|
|
func RedisClusterSet(key string, val interface{}, timeout int) bool {
|
|
|
- resullt, err := RedisCluster.Set(ctx, key, val, time.Duration(timeout)*time.Second).Result()
|
|
|
- if err != nil || resullt != "OK" {
|
|
|
- log.Println("Redis Cluster Set Error:", resullt, err)
|
|
|
+ result, err := RedisCluster.Set(ctx, key, val, time.Duration(timeout)*time.Second).Result()
|
|
|
+ if err != nil || result != "OK" {
|
|
|
+ log.Println("Redis Cluster Set Error:", result, err)
|
|
|
return false
|
|
|
}
|
|
|
return true
|
|
@@ -33,16 +33,18 @@ func RedisClusterSet(key string, val interface{}, timeout int) bool {
|
|
|
|
|
|
//get
|
|
|
func RedisClusterGet(key string) string {
|
|
|
- resullt, _ := RedisCluster.Get(ctx, key).Result()
|
|
|
- return resullt
|
|
|
+ result, _ := RedisCluster.Get(ctx, key).Result()
|
|
|
+ return result
|
|
|
}
|
|
|
|
|
|
//exists
|
|
|
func RedisClusterExists(key string) bool {
|
|
|
- resullt, err := RedisCluster.Exists(ctx, key).Result()
|
|
|
- if err != nil || resullt != 1 {
|
|
|
- log.Println("Redis Cluster Exists Error:", resullt, err)
|
|
|
- return false
|
|
|
+ result, err := RedisCluster.Exists(ctx, key).Result()
|
|
|
+ if result == 1 && err == nil {
|
|
|
+ return true
|
|
|
}
|
|
|
- return true
|
|
|
+ if err != nil {
|
|
|
+ log.Println("Redis Cluster Exists Error:", result, err)
|
|
|
+ }
|
|
|
+ return false
|
|
|
}
|