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 }
Cache is a typed cache implementation, leveraging xsync.Map for concurrency safety.
func (*Cache[K, V]) Create ¶
Create stores the given key-value pair, if it does not already exist, and returns whether the provided key already existed before. Create uses xsync.Map.LoadOrStore().
func (*Cache[K, V]) Delete ¶
func (c *Cache[K, V]) Delete(key K)
Delete simply removes the given key from the typed cache. Delete uses a write-lock via xsync.Map.Delete().
func (*Cache[K, V]) Exists ¶
Exists returns whether the given key is already set. Exists uses xsync.Map.Load().
func (*Cache[K, V]) Length ¶
Length returns the amount of key-value pairs currently maintained in the underlying cache. Length uses xsync.Map.Size().
type Interface ¶
type Interface[K comparable, V any] interface { Create(K, V) bool Delete(K) Exists(K) bool Length() int Search(K) (V, bool) Update(K, V) }
Interface defines a generic concurrency safe key-value cache used to communicate between packages.
func New ¶
func New[K comparable, V any]() Interface[K, V]