Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache implements a cache that loads an entry upon first access (using the provided loader), caches it, and then (if required) periodically refreshes the cache entry according the configured refresh interval. While the entry is being refreshed callers are served the old value of the entry. If a refresh fails then the old value is served and another refresh is attempted at a later time. Refreshing an entry does not cause requests for the entry to be blocked, unless the value of the entry is nil.
func (*Cache) MarkAsStale ¶
func (c *Cache) MarkAsStale(key interface{})
MarkAsStale marks the entry such that it should load immediately (or as soon as possible) without waiting for the next refresh time.
type Opt ¶
type Opt func(opts *options)
Opt specifies a config retriever option.
func WithMaxLoadAttempts ¶
WithMaxLoadAttempts specifies the maximum number of attempts to unsuccessfully load an entry before it is removed from the cache. (Default is to try forever.)
func WithMonitorInterval ¶
WithMonitorInterval specifies the interval at which entries are checked if they need to be refreshed.
func WithRefreshInterval ¶
WithRefreshInterval sets the interval at which each entry in the cache is refreshed. If set to 0 (default) then the items will not be refreshed.
func WithRetryBackoff ¶
WithRetryBackoff specifies the interval at which an entry in the cache errored out at the last attempt is retried.