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. duration and maxSize are initialized to their default values but should be configured using WithExpirationInterval and WithMaxSize options.
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.
type Option ¶ added in v1.49.0
type Option func(*Cache)
Option function to configure a Cache
func WithCachedEntriesMetric ¶ added in v1.49.0
func WithCachedEntriesMetric(m *prometheus.GaugeVec) Option
func WithCachedRequestsMetric ¶ added in v1.49.0
func WithCachedRequestsMetric(m *prometheus.CounterVec) Option
func WithExpirationInterval ¶ added in v1.49.0
func WithMaxSize ¶ added in v1.49.0
Click to show internal directories.
Click to hide internal directories.