Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache wraps a ccache and allows setting custom metrics for hits/misses.
func New ¶
func New(op string, maxEntries int64, duration time.Duration, cachedEntriesMetric *prometheus.GaugeVec, cacheRequestsMetric *prometheus.CounterVec) *Cache
New creates an LRU cache
func (*Cache) FindOrFetch ¶
func (c *Cache) FindOrFetch(cacheNamespace, key string, fetchFn func() (interface{}, error)) (interface{}, error)
FindOrFetch will try to get the item from the cache if exists and is not expired. If it can't find it, it will call fetchFn to retrieve the item and cache it.
Click to show internal directories.
Click to hide internal directories.