eko / gocache

☔️ A complete Go cache library that brings you multiple ways of managing your caches
https://vincent.composieux.fr/article/i-wrote-gocache-a-complete-and-extensible-go-cache-library/
MIT License
2.4k stars 193 forks source link

ChainCache.Get failing with BigCache store v4.2.0 (GetWithTTL not implemented error) #225

Open butaca opened 11 months ago

butaca commented 11 months ago

When using BigCache in a chain, ChainCache.Get fails because it uses GetWithTTL and that function in BigCache is not implemented and returns an error. The change was merged recently: https://github.com/eko/gocache/commit/d94f5d2c9ced337b74fe48434f6f141188e9a85a in big cache store v4.2.0 https://github.com/eko/gocache/compare/store/bigcache/v4.1.2...store/bigcache/v4.2.0

Steps for Reproduction

  1. Set up a chain cache with a BigCache store

    bigcacheClient, _ := bigcache.New(ctx, bigcache.DefaultConfig(5 * time.Minute))
    bigcacheStore := bigcache_store.NewBigcache(bigcacheClient)
    bigCacheCache := cache.New[[]byte](bigcacheStore)
    chain := cache.NewChain[[]byte](bigCacheCache)
  2. Get a value

_, err := chain.Get(ctx, "key")
fmt.Printf("%v\n", err)
  1. See how it returns an error

Expected behavior: The function does not return an error

Actual behavior: The function returns an error

Platforms:

macOS and dockerized Linux from scratch

Versions:

gocache v4.1.4 go 1.21 BigCache store v4.2.0 BigCache v3.1.0