Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
cache
✓ github.com/go-redis/cache/v9
Set and get a value from Redis cache
package main
import (
"context"
"fmt"
"github.com/go-redis/cache/v9"
"github.com/redis/go-redis/v9"
)
func main() {
ring := redis.NewRing(&redis.RingOptions{
Addrs: map[string]string{"server": ":6379"},
})
mycache := cache.New(&cache.Options{
Redis: ring,
})
ctx := context.Background()
key := "greeting"
if err := mycache.Set(&cache.Item{
Ctx: ctx,
Key: key,
Value: "hello",
}); err != nil {
panic(err)
}
var value string
if err := mycache.Get(ctx, key, &value); err != nil {
panic(err)
}
fmt.Println(value)
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
9.0.0latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.