nitishm / go-rejson

Golang client for redislabs' ReJSON module with support for multilple redis clients (redigo, go-redis)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set Go Redis V7 Client Problem

rainlay opened this issue · comments

commented

HI, I want so set the goredis/v7 to use rejson, but when I set the client,

the error shows:

Cannot use (type *"github.com/go-redis/redis/v7".Client) as type *"github.com/go-redis/redis".Client 

looks like the lib only accept "github.com/go-redis/redis" (v6),

can fix the problem? thanks..

Is there a particular reason you need to upgrade to v7 ? Not that it is not possible, I am just curious to know.

commented

Is there a particular reason you need to upgrade to v7 ? Not that it is not possible, I am just curious to know.

not for a really necessary reason, I was just using the newest version for go-redis, maybe I will rollback to v6 for using rejson...

We could update the go mod with the latest, but I suspect you are not using go modules. If you switch to go modules in your project it should select the lowest compatible version (in this case v6) unless you explicitly import v7 in your source.

commented

Hi nitishm, I am using go mod, I was explicitly import go-redis v7 version (follow the go-redis github readme)

Hi, is the upgrade to go-redis v7 still on hold right now? I would love to use rejson with the new client as v7 fixes some major issues with commands like HMSet and, while it's no dealbreaker, importing two different versions of go-redis seems kind of unfortunate.

@nitishm Hi! Why don't you like interfaces?
cannot use redisCli (type *"github.com/go-redis/redis/v7".Client) as type *"github.com/go-redis/redis".Client in argument to rh.SetGoRedisClient

@filinvadim I am open to switching to interfaces. Feel free to take on the task and open a PR if you feel up to it 😄 . If not @Shivam010 would you be willing to take this on?

Sure, I'll look into this by the week end

@nitishm There can be two possible solutions to the problem.

  1. Using an interface with a Do(...interface{}) (interface{}, error) method instead of the go-redis clients
  2. Or we can release a new version by manually updating the client version.

The first one will remove the client version dependency but will require the user to wrap the client object into the interface.
And the second one will only require a version change in go mod for the corresponding client version.

Prefer the 2nd one @Shivam010