bsm / redislock

Simplified distributed locking implementation using Redis
Other
1.45k stars 157 forks source link

Doesn't work with redis/v9 #46

Closed rv-nath closed 2 years ago

rv-nath commented 2 years ago

When I have this code

rc := GetRedisClient()
locker  := redislock.New(rc)

And my redis helper file, uses redis v9 like below..

package main

import (
  "github.com/ilyakaznacheev/cleanenv"
  "github.com/go-redis/redis/v9"
  "github.com/rs/zerolog/log"
)

 ...
 ...

func GetRedisClient() *redis.Client{

  if client == nil {
    //fmt.Println("Obtaining a connection to Redis...")
    log.Print("Obtaining connection to Redis...")
    client = redis.NewClient(&redis.Options{
      Addr: cfg.Addr,
      Password: cfg.Password,
      DB: cfg.DB,
    })
  } else {
    log.Print("Reusing connection to Redis...")
  }
  return client
}

Then, I get an error cmd/app/game-controller.go:85:27: cannot use rc (variable of type "github.com/go-redis/redis/v9".Client) as type redislock.RedisClient in argument to redislock.New: "github.com/go-redis/redis/v9".Client does not implement redislock.RedisClient (wrong type for Eval method) have Eval(ctx context.Context, script string, keys []string, args ...interface{}) "github.com/go-redis/redis/v9".Cmd want Eval(ctx context.Context, script string, keys []string, args ...interface{}) "github.com/go-redis/redis/v8".Cmd make: *** [makefile:8: build] Error 2

dim commented 2 years ago

Hi, the library is still working with v8 since v9 is only in beta. We will release a new/updated version shortly.

dim commented 2 years ago

See #47

kamikazechaser commented 2 years ago

Just a heads up. go-redis v9 is not backward compatible with redis v6 (https://github.com/go-redis/redis/issues/2222). I suggest putting a notice on the README wrt this issue.