Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong type for method Del when initialize Redis Store #12

Closed
Yosafat1997 opened this issue Nov 7, 2019 · 5 comments
Closed

Wrong type for method Del when initialize Redis Store #12

Yosafat1997 opened this issue Nov 7, 2019 · 5 comments

Comments

@Yosafat1997
Copy link

I want to implement a chained cache with Redis and BigCache. I don't have problem to declare Bigcache store, but have problem with redis. I using redis from "github.com/go-redis/redis", gocache store and gocache cache

this is how i declare my cache:

var LocationCache *cache.ChainCache

func createCache(host string) *cache.ChainCache {
	redisClient := redis.NewClient(&redis.Options{Addr: host})
	bigcacheClient, _ := bigcache.NewBigCache(bigcache.DefaultConfig(720 * time.Hour))
	bigcacheStorage := store.NewBigcache(bigcacheClient, nil)
	redisStorage := store.NewRedis(redisClient, nil)

	LocationCache = cache.NewChain(
		cache.New(bigcacheStorage),
		cache.New(redisStorage))
	return LocationCache
}

But it give me this error: cannot use redisClient (variable of type *redis.Client) as store.RedisClientInterface value in argument to store.NewRedis: wrong type for method Del"

Is anyone can help me? Thanks

@eko
Copy link
Owner

eko commented Nov 7, 2019

Hi @Yosafat1997,

I think it is because I used the latest version of the https://github.com/go-redis/redis library.

Indeed, could you move your import to the v7:

import "github.com/go-redis/redis/v7"

This way, the following Del method:

https://github.com/go-redis/redis/blob/master/commands.go#L61

should match the specified interface in the Gocache library:

https://github.com/eko/gocache/blob/master/store/redis.go#L15

I hope it helps. Please close this issue if it is fixed, elsewhere I will have a closer look as soon as possible.

Thank you

@Yosafat1997
Copy link
Author

oh okay,but if you don't mind, is there any possibilities to update this library to follow latest version of its dependencies, such as redis and all caches type that covered by this library?

@eko
Copy link
Owner

eko commented Nov 7, 2019

Yep, this is the latest version actually, I think you could also try with master branch instead of latest v7 tag:

$ go get github.com/go-redis/redis@master

@Yosafat1997
Copy link
Author

Oh sorry my mistake... i mean if you want to update this library in future.

@eko
Copy link
Owner

eko commented Nov 8, 2019

I prefer to be based on semantic versioning and so use the v7 release tags, I will update it in case on new releases :)

Thank you for reporting this feedback!

@eko eko closed this as completed Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants