Hi,
i discovered your awesome library today and im trying to run the examples on the readme.
i get the below errors when i try to run them
1)
`
bigcacheClient, _ := bigcache.NewBigCache(bigcache.DefaultConfig(5 * time.Minute))
bigcacheStore := store.NewBigcache(bigcacheClient, nil)
cacheManager := cache.New(bigcacheStore)
err := cacheManager.Set("my-key", "my-value", nil)
if err != nil {
panic(err)
}
value, err := cacheManager.Get("my-key")
log.Println(value, err)
`
im getting an error marked at err := cacheManager.Set("my-key", "my-value", nil)
panic: interface conversion: interface {} is string, not []uint8
goroutine 1 [running]:
github.com/eko/gocache/store.(*BigcacheStore).Set(0xc00019c660, 0x773a20, 0xc000032000, 0x773a20, 0x86e010, 0x0, 0xc00000e201, 0xc000032000)
D:/Dev/GOPATH/pkg/mod/github.com/eko/[email protected]/store/bigcache.go:62 +0x19d
github.com/eko/gocache/codec.(*Codec).Set(0xc00019c680, 0x773a20, 0xc000032000, 0x773a20, 0x86e010, 0x0, 0x875001, 0xc000012140)
D:/Dev/GOPATH/pkg/mod/github.com/eko/[email protected]/codec/codec.go:51 +0x70
github.com/eko/gocache/cache.(*Cache).Set(0xc00016bed8, 0x773a20, 0x86e000, 0x773a20, 0x86e010, 0x0, 0x875860, 0xb18120)
D:/Dev/GOPATH/pkg/mod/github.com/eko/[email protected]/cache/cache.go:39 +0xa2
main.main()
D:/Dev/GOPATH/src/gokit/examples/cache/main.go:17 +0x28e
exit status 2
Alternatively when im using the example in the benchmark directly on the store, it works
`
client, _ := bigcache.NewBigCache(bigcache.DefaultConfig(5 * time.Minute))
store := store.NewBigcache(client, nil)
key := "test"
value := []byte("value")
store.Set(key, value, nil)
val, err := store.Get(key)
ba := []byte{}
for _, b := range val.([]uint8) {
ba = append(ba, byte(b))
}
log.Println(string(ba), err)
`
`
import (
"log"
"github.com/dgraph-io/ristretto"
"github.com/eko/gocache/cache"
"github.com/eko/gocache/store"
)
func main() {
ristrettoCache, err := ristretto.NewCache(&ristretto.Config{
NumCounters: 1000,
MaxCost: 100,
BufferItems: 64,
})
if err != nil {
panic(err)
}
ristrettoStore := store.NewRistretto(ristrettoCache, nil)
cacheManager := cache.New(ristrettoStore)
err = cacheManager.Set("my-key", "my-value", &cache.Options{Cost: 2})
if err != nil {
panic(err)
}
value, err := cacheManager.Get("my-key")
log.Println(value, err)
cacheManager.Delete("my-key")
}
`
err:
.\main.go:23:48: undefined: cache.Options
i noticed options struct is in store package which is imported.
Could you please help