Git Product home page Git Product logo

Comments (6)

spbjss avatar spbjss commented on August 29, 2024

I got this error: unknown compression method: 39

Here is the code:

var value string
err := Get(ctx, "key", value)

func Get(ctx context.Context, key string, dest interface{}){
  dest interface{}
  err = cache.Cache.Get(ctx, key, &dest)
}

from cache.

spbjss avatar spbjss commented on August 29, 2024

It seems the compression method cannot be recognized.

cache/cache.go

Line 399 in 8756f3b

return fmt.Errorf("unknown compression method: %x", c)

from cache.

vincentluan avatar vincentluan commented on August 29, 2024

@spbjss yes it does. But it shouldn't happen though.

from cache.

XeQtr792 avatar XeQtr792 commented on August 29, 2024

@vincentluan you should be passing variable of specific type when trying to load value from cache and not generic interface. Un-marshal doesn't know how to un-marshal when you give it a generic interface.

try this if cacheValue is string

import (
	"context"
	"time"

	"github.com/go-redis/cache/v8"
	"github.com/go-redis/redis/v8"
)

timeout := 15 * time.Second
ring := redis.NewRing(&redis.RingOptions{
	Addrs: map[string]string{
		"shard1": ":6379",
	},
	DialTimeout:  timeout,
	ReadTimeout:  timeout,
	WriteTimeout: timeout,
})

c := cache.New(&cache.Options{
	Redis: ring,
})

var wanted string **// or whatever object you are expecting value to un-marshal into  or provide custom un-marhsaller for your object**
err := c.GetSkippingLocalCache(context.TODO(), "key", &wanted)
if err != nil {
	panic(err)
}

from cache.

akhromium avatar akhromium commented on August 29, 2024

I came up to same conclusion as @XeQtr792, but It's not very neat..
This is not what I expected using this library.

from cache.

vincentluan avatar vincentluan commented on August 29, 2024

@XeQtr792 It doesn't seem to be the case because it's working correctly in my other projects.
Anyway it seems the issue is fixed with the following versions. Thank you guys for your comments.

github.com/go-redis/cache/v8 v8.4.3
github.com/go-redis/redis/v8 v8.11.4

from cache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.