🐛 Trying to fix cache sdk issue
This commit is contained in:
parent
e7d7cd1000
commit
488793a2dc
@ -21,8 +21,8 @@ func Set[T any](c *CaConn, key string, value T, ttl time.Duration, tags ...strin
|
|||||||
|
|
||||||
ctx, cancel := c.withTimeout()
|
ctx, cancel := c.withTimeout()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
cm := cache.New[[]byte](c.GoCache())
|
cm := cache.New[string](c.GoCache())
|
||||||
return cm.Set(ctx, key, raw, store.WithTags(tags), store.WithExpiration(ttl))
|
return cm.Set(ctx, key, string(raw), store.WithTags(tags), store.WithExpiration(ttl))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetKA stands for Set Keep Alive
|
// SetKA stands for Set Keep Alive
|
||||||
@ -35,8 +35,8 @@ func SetKA[T any](c *CaConn, key string, value T, tags ...string) error {
|
|||||||
|
|
||||||
ctx, cancel := c.withTimeout()
|
ctx, cancel := c.withTimeout()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
cm := cache.New[[]byte](c.GoCache())
|
cm := cache.New[string](c.GoCache())
|
||||||
return cm.Set(ctx, key, raw, store.WithTags(tags))
|
return cm.Set(ctx, key, string(raw), store.WithTags(tags))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Get[T any](c *CaConn, key string) (T, error) {
|
func Get[T any](c *CaConn, key string) (T, error) {
|
||||||
@ -44,13 +44,13 @@ func Get[T any](c *CaConn, key string) (T, error) {
|
|||||||
|
|
||||||
ctx, cancel := c.withTimeout()
|
ctx, cancel := c.withTimeout()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
cm := cache.New[[]byte](c.GoCache())
|
cm := cache.New[string](c.GoCache())
|
||||||
raw, err := cm.Get(ctx, key)
|
raw, err := cm.Get(ctx, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(raw, &out); err != nil {
|
if err := json.Unmarshal([]byte(raw), &out); err != nil {
|
||||||
return out, fmt.Errorf("unable to unmarshal value during caching: %v", err)
|
return out, fmt.Errorf("unable to unmarshal value during caching: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user