Skip to content
/ mem Public

gokv/store compliant in-memory key value store

License

Notifications You must be signed in to change notification settings

gokv/mem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
}

About

gokv/store compliant in-memory key value store

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages