gokv/store compliant in-memory key value store
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
cleanup.go
cleanup_test.go
doc.go
go.mod
store.go
store_test.go

README.md

gokv/mem

GoDoc Build Status

An in-memory key-value store implementing the github.com/gokv/store Store interface.

The focus is on readability and simplicity.

Usage

func main() {
	s := mem.New()
	defer s.Close() // close the mem.Store to avoid leaking goroutines

	err := s.SetWithTimeout(context.Background(), "key", Value{p:1}, timeout)
	if err != nil {
		panic(err)
	}

	var v Value // Value is a type that implements json.Marshaler/Unmarshaler
	ok, err := s.Get(context.Background(), "key", &v)

	if err != nil {
		panic(err)
	}

	if !ok {
		panic(errors.New("Value not found!"))
	}

	fmt.Println("The retrieved value is %q", v)
}