go-redis / cache

Cache library with Redis backend for Golang
https://redis.uptrace.dev/guide/go-redis-cache.html
BSD 2-Clause "Simplified" License
757 stars 95 forks source link

Any plans for support for other data types? #30

Closed leesio closed 4 years ago

leesio commented 4 years ago

Firstly, thanks for building this. I like the design of the library as a wrapper around the redis client.

I'm curious whether you have any plans to support other redis data types (e.g. hash/set)? If there aren't fundamental issues supporting other data types I might be interested in implementing them.

vmihailenco commented 4 years ago

I don't have such plans and it is not clear how hash/set can be useful for caching.

leesio commented 4 years ago

It seems like it would be useful to cache hash/set values for same reason it's useful to cache string values: to avoid a trip to redis for every read.

Maybe I'm misunderstanding something?

vmihailenco commented 4 years ago

I am not sure what you mean - an example may help...

leesio commented 4 years ago

I think I might have slightly misunderstood this library on first glance.

I understood that the primary use of this library was to add a process local cache in front of redis.

cache := &cache.Cache{Redis: redisClient}

var result map[string]interface{}
err := cache.Get(ctx, "some-key", &result) // requires a round trip to redis

At another call point, a round trip to redis could be avoided

var otherResult map[string]interface{}
err := cache.Get(ctx, "some-key", &otherResult) // does not require a round trip to redis, since the value is cached locally

I imagined that this could be applicable to other data structure.

vmihailenco commented 4 years ago

No, this is a key/value cache based on Redis, not for Redis.

leesio commented 4 years ago

I now understand why my initial comment didn't make much sense. Sorry for wasting your time!