Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expiring ¶
type Expiring[K comparable, V any] struct { // contains filtered or unexported fields }
Expiring is a pool of elements associated with string keys that have an expiration time after no one is using them.
The elements will be evicted from the pool only on the next Get function call or Prune function call. There is no assurances that the eviction will happen at the expiration time, just that it will not happen before.
func NewExpiring ¶
func NewExpiring[K comparable, V any]( constructor func(key K) (V, error), destructor func(V) error, ) *Expiring[K, V]
NewExpiring creates a new Expiring pool with constructor and destructor for functions for pool elements.
func (*Expiring[K, V]) Clear ¶
Clear removes all elements in the pool regardless if they are expired or not.
func (*Expiring[K, V]) Get ¶
Get retrieves a value from the pool referenced by the key. If the value is not in the pool, a new instance will be created using the pool's constructor function.