gocache
gocache copied to clipboard
ChainCache returns default value with no caches configured
Our application has configuration options to set up the caching hierarchy. If none of them are configured, we end up with a ChainCache with no stores configured. When this happens, Get() returns a default-constructed value type rather than an error. For example, ChainCache[[]byte].Get() returns a 0-length []byte.
Steps for Reproduction
- Configure a
ChainCache[[]byte]with no stores. - Call
cache.Get()and observe the result coming back
Expected behavior:
Get() returns an error of some sort.
Actual behavior:
Get() returns a default-constructed value which looks like a cache hit, but is really malformed data.
Versions:
lib/v4 v4.2.0
Hi @pgcamus,
Thank you for this feedback.
Please feel free to open a pull request to return an error when no cache is given.