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]) Clear ¶
func (c *Cache[K, V]) Clear()
Clear removes all entries from the cache. It resets the innerMap to an empty state.
func (*Cache[K, V]) Evict ¶
Evict removes the entry with the specified key from the cache. It returns true if the entry was successfully evicted, and false otherwise.
func (*Cache[K, V]) GetOrLoad ¶
GetOrLoad retrieves the value associated with the specified key from the cache. If the entry does not exist, it calls the provided `loadFunc` function to load the value and store it in the cache. The `loadFunc` function should have the signature `func(k K) (V, error)`.
Click to show internal directories.
Click to hide internal directories.