Documentation ¶
Index ¶
- type InMemStore
- func (p *InMemStore[K, T]) All() []T
- func (p *InMemStore[K, T]) Delete(key K)
- func (p *InMemStore[K, T]) Get(key K) (T, bool)
- func (p *InMemStore[K, T]) GetAndDelete(key K) (T, bool)
- func (p *InMemStore[K, T]) IsZero() bool
- func (p *InMemStore[K, T]) Len() int
- func (p *InMemStore[K, T]) Put(key K, data T)
- func (p *InMemStore[K, T]) Query(spec QueryFunc[K, T], limit int) []T
- func (p *InMemStore[K, T]) Update(key K, updates ...UpdateFunc[K, T])
- type QueryFunc
- type Store
- type UpdateFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InMemStore ¶
type InMemStore[K comparable, T any] struct { // contains filtered or unexported fields }
InMemStore in-memory peer store
func NewInMemStore ¶
func NewInMemStore[K comparable, V any]() *InMemStore[K, V]
NewInMemStore creates a new in-memory peer store
func (*InMemStore[K, T]) All ¶
func (p *InMemStore[K, T]) All() []T
All returns all stored values in the store
func (*InMemStore[K, T]) Delete ¶
func (p *InMemStore[K, T]) Delete(key K)
Delete removes the peer data from the store
func (*InMemStore[K, T]) Get ¶
func (p *InMemStore[K, T]) Get(key K) (T, bool)
Get returns peer's data and true if the peer is found otherwise empty structure and false
func (*InMemStore[K, T]) GetAndDelete ¶
func (p *InMemStore[K, T]) GetAndDelete(key K) (T, bool)
GetAndDelete combines Get operation and Delete in one call
func (*InMemStore[K, T]) IsZero ¶
func (p *InMemStore[K, T]) IsZero() bool
IsZero returns true if the store doesn't have a peer yet otherwise false
func (*InMemStore[K, T]) Len ¶
func (p *InMemStore[K, T]) Len() int
Len returns the count of all stored values
func (*InMemStore[K, T]) Put ¶
func (p *InMemStore[K, T]) Put(key K, data T)
Put adds the peer data to the store if the peer does not exist, otherwise update the current value
type QueryFunc ¶
type QueryFunc[K comparable, V any] func(key K, data V) bool
QueryFunc is a function type for a specification function
func AndX ¶
func AndX[K comparable, V any](specs ...QueryFunc[K, V]) QueryFunc[K, V]
AndX combines multiple specification functions into one
type UpdateFunc ¶
type UpdateFunc[K comparable, V any] func(key K, item *V)
UpdateFunc is a function type for an item update functions