Documentation ¶
Index ¶
- type InMemoryRepo
- func (r *InMemoryRepo[Entry]) Delete(key string)
- func (r *InMemoryRepo[Entry]) Find(filter func(Entry) bool) []Entry
- func (r *InMemoryRepo[Entry]) FindByKey(key string) (Entry, bool)
- func (r *InMemoryRepo[Entry]) Store(entry Entry)
- func (r *InMemoryRepo[Entry]) Update(key string, updater func(entry Entry, found bool) (Entry, error)) (Entry, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InMemoryRepo ¶
type InMemoryRepo[Entry any] struct { // contains filtered or unexported fields }
InMemoryRepo is a simple in-memory repository implementation. It is thread-safe, so it should be wrapped in a mutex.
func NewInMemoryRepo ¶
func NewInMemoryRepo[Entry any](keyFn func(Entry) string) *InMemoryRepo[Entry]
func (*InMemoryRepo[Entry]) Delete ¶
func (r *InMemoryRepo[Entry]) Delete(key string)
func (*InMemoryRepo[Entry]) Find ¶
func (r *InMemoryRepo[Entry]) Find(filter func(Entry) bool) []Entry
func (*InMemoryRepo[Entry]) FindByKey ¶
func (r *InMemoryRepo[Entry]) FindByKey(key string) (Entry, bool)
func (*InMemoryRepo[Entry]) Store ¶
func (r *InMemoryRepo[Entry]) Store(entry Entry)
Click to show internal directories.
Click to hide internal directories.