Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LRUExpireCache ¶ added in v1.0.0
type LRUExpireCache[K comparable, T any] struct { // contains filtered or unexported fields }
LRUExpireCache is a drop in replacement for the apimachinery version that makes it typed with generics, and also data immutable via deep copies.
func NewLRUExpireCache ¶ added in v1.0.0
func NewLRUExpireCache[K comparable, T any](maxSize int) *LRUExpireCache[K, T]
func (*LRUExpireCache[K, T]) Add ¶ added in v1.0.0
func (c *LRUExpireCache[K, T]) Add(key K, value T, ttl time.Duration)
func (*LRUExpireCache[K, T]) Get ¶ added in v1.0.0
func (c *LRUExpireCache[K, T]) Get(key K) (T, bool)
type TimeoutCache ¶
type TimeoutCache[V any] struct { // contains filtered or unexported fields }
TimeoutCache provides a cache with timeout.
func NewWithClock ¶ added in v1.11.0
func NewWithClock[V any](refresh time.Duration, c clock) *TimeoutCache[V]
func (*TimeoutCache[V]) Get ¶
func (m *TimeoutCache[V]) Get() (value V, ok bool)
Get returns the cached value if set and it hasn't timed out and returns true. If it has timed out, it will return V's zero value and false, and will need to be set again.
func (*TimeoutCache[V]) Invalidate ¶ added in v1.11.0
func (m *TimeoutCache[V]) Invalidate()
func (*TimeoutCache[V]) Set ¶
func (m *TimeoutCache[V]) Set(value V)
Set remembers the value and resets the invalid time based on when the cache was set.
Click to show internal directories.
Click to hide internal directories.