Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
func (*Cache[K, V]) EvictEntry ¶
func (*Cache[K, V]) EvictExpiredEntries ¶
func (c *Cache[K, V]) EvictExpiredEntries()
func (*Cache[K, V]) GetOrCreateCacheEntry ¶
type CacheWithErr ¶
type CacheWithErr[K comparable, V any] struct { // contains filtered or unexported fields }
func NewWithError ¶
func NewWithError[K comparable, V any](ttl, errTtl time.Duration, errCacher ErrCacher[K], tracer trace.Tracer, isCacheableFunc func(error) bool) *CacheWithErr[K, V]
func (*CacheWithErr[K, V]) GetItem ¶
func (c *CacheWithErr[K, V]) GetItem(ctx context.Context, key K, f GetItemDirectly[V]) (V, error)
type Entry ¶
type Entry[V any] struct { // protects state in this object. syncz.Mutex // Expires holds the time when this entry should be removed from the cache. Expires time.Time // Item is the cached item. Item V HasItem bool }
func (*Entry[V]) IsNeedRefreshLocked ¶
type ErrCacher ¶
type ErrCacher[K any] interface { // GetError retrieves a cached error. // Returns nil if no cached error found or if there was a problem accessing the cache. GetError(ctx context.Context, key K) error // CacheError puts error into the cache. CacheError(ctx context.Context, key K, err error, errTtl time.Duration) }
type GetItemDirectly ¶
Click to show internal directories.
Click to hide internal directories.