Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface[K constraints.Ordered, V ValueInterface] interface { // Get looks up a key's value from the key-value store. Ok is false if not found. Get(key K) (value *V, ok bool) // Set sets a value to the key-value store with key, replacing any existing value. Set(key K, val *V) // Keys returns the keys of the key-value store. The order is relied on algorithms. Keys() []K // Delete deletes the item with provided key from the key-value store. Delete(key K) // Contains reports whether the given key is stored within the key-value store. Contains(key K) bool // Iterate iterates over all the items in the key-value store and calls given function with key, value and options. Iterate(fn func(key K, value *V) error) error }
Interface is a common key-value store interface.
type Item ¶
type Item[K constraints.Ordered, V ValueInterface] struct { Key K Value V }
Item is an kvstore item
type KVStore ¶
type KVStore[K constraints.Ordered, V ValueInterface] struct { // contains filtered or unexported fields }
KVStore is a thread safe key-value store.
func New ¶
func New[K constraints.Ordered, V ValueInterface]() *KVStore[K, V]
New creates a new thread safe key-value store.
func (*KVStore[K, V]) Contains ¶
Contains reports whether the given key is stored within the key-value store.
func (*KVStore[K, V]) Delete ¶
func (c *KVStore[K, V]) Delete(key K)
Delete deletes the item identified with the given key from the key-value store.
func (*KVStore[K, V]) Iterate ¶
Iterate iterates over all the items in the key-value store and calls given function with key, value and options.
Click to show internal directories.
Click to hide internal directories.