Documentation
¶
Overview ¶
Package cache wraps a registry.Discovery with a resilient read-through cache inspired by go-micro's registry cache. It adds, on top of the underlying discovery: singleflight deduplication of concurrent lookups, a service-level TTL and per-node TTL, stale-while-error degradation when the registry fails, and a minimum retry interval that throttles refresh attempts to avoid cache stampedes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*Options)
Option configures a cache.
func WithMinRetryInterval ¶
WithMinRetryInterval sets the minimum interval between registry refresh attempts for a service.
func WithNodeTTL ¶
WithNodeTTL sets the per-node cache TTL.
type Options ¶
type Options struct {
TTL time.Duration
NodeTTL time.Duration
MinRetryInterval time.Duration
// Now is the clock used for TTL decisions; tests inject a fake clock. It
// lives in Options (rather than a package-level variable) so concurrent
// caches with different clocks never race.
Now func() time.Time
}
Options holds cache tunables.
Click to show internal directories.
Click to hide internal directories.