Open zclyne opened 6 months ago
cacheManager := cache.NewMetric[any](promMetrics, gocacheStore)
这行错了,应该
cacheManager := cache.NewMetric[any](promMetrics, cache.New[any](gocacheStore))
It is working fine now. Thank you so much!
It seems that goCacheStore
object implements the StoreInterface
interface while NewMetric
takes a CacheInterface
, but StoreInferface
happens to implement CacheInterface
, therefore the compiler is happy with it but in fact it is wrong in terms of program logic. I wonder if we can separate these two interfaces in case people run into issues like this again?
Apologies that I don't have Chinese input on this computer. I appreciate your help!
Hi, I was trying to use
go-cache
as a backend cache for a cache with prometheus metrics. I expose the prometheus metrics via httplocalhost:8080/metrics
but this endpoint returns empty response, i.e. no metrics.Steps for Reproduction
After inspecting the code I found that
gocacheStore
doesn't implement theSetterCacheInterface
interface, which causesswitch...case...
miss defined in the function below https://github.com/eko/gocache/blob/96fc2f790c4cfb27659863657625fa8c4e68d25d/lib/cache/metric.go#L63-L73Expected behavior: metrics should be updated and collected by the prometheus registry
Actual behavior: no metrics collected
Platforms:
Go: 1.20 Linux: 3.10.0-1160.105.1.el7.x86_64
Versions:
github.com/eko/gocache/lib/v4 v4.1.5 github.com/eko/gocache/store/go_cache/v4 v4.2.1
If fixing this issue will be on the roadmap, I can help contribute. Thanks!