xrepo

package
v2.5.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

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)

func (*InMemoryRepo[Entry]) Update

func (r *InMemoryRepo[Entry]) Update(key string, updater func(entry Entry, found bool) (Entry, error)) (Entry, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL