Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentMap ¶
type ConcurrentMap[K comparable, V any] struct { // contains filtered or unexported fields }
ConcurrentMap is a thread-safe map with lazy computation capabilities.
func NewConcurrentMap ¶
func NewConcurrentMap[K comparable, V any]() *ConcurrentMap[K, V]
NewConcurrentMap creates a new ConcurrentMap.
func (*ConcurrentMap[K, V]) Delete ¶
func (m *ConcurrentMap[K, V]) Delete(key K)
Delete removes the key from the map.
func (*ConcurrentMap[K, V]) Get ¶
func (m *ConcurrentMap[K, V]) Get(key K) (V, bool)
Get retrieves the value for the given key from the map.
func (*ConcurrentMap[K, V]) GetOrCompute ¶
func (m *ConcurrentMap[K, V]) GetOrCompute(key K, compute func() (V, error)) (V, error)
GetOrCompute retrieves the value for the given key from the map, or computes it using the provided function if not present.
func (*ConcurrentMap[K, V]) Set ¶
func (m *ConcurrentMap[K, V]) Set(key K, value V)
Set sets the value for the given key in the map.
type ExpiringMap ¶
type ExpiringMap[K comparable, V any] struct { // contains filtered or unexported fields }
ExpiringMap is a thread-safe map that automatically expires entries based on a validity function.
func NewExpiringMap ¶
func NewExpiringMap[K comparable, V any](isValid func(value V) bool) *ExpiringMap[K, V]
NewExpiringMap creates a new ExpiringMap with the specified validity function.
func (*ExpiringMap[K, V]) GetOrCompute ¶
func (m *ExpiringMap[K, V]) GetOrCompute(key K, compute func() (V, error)) (V, error)
GetOrCompute retrieves the value for the given key from the map, or computes it using the provided function if not present or expired.
func (*ExpiringMap[K, V]) Set ¶
func (m *ExpiringMap[K, V]) Set(k K, v V)
Set sets the value for the given key in the map.