You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
store is a data-store library for Go that provides a set of platform-independent interfaces to persist and retrieve data.
Its primary goal is to wrap existing implementations of such primitives, such as those in package redis, into shared public interfaces that abstract functionality, plus some other related primitives.
It currently supports Redis from the redis package.
NOTE: This library is currently under active development and not ready for production use.
Example
The below example stores, lists and fetches the saved records
package main
import (
"fmt""github.com/gosuri/go-store/redis"
)
typehackerstruct {
IdstringNamestringBirthyearint
}
func (h*hacker) Key() string {
returnh.Id
}
func (h*hacker) SetKey(kstring) {
h.Id=k
}
funcmain() {
store, err:=redis.NewStore("", "")
iferr!=nil {
panic(err) // handle error
}
// Save a hacker in the store with a auto-generated uuidiferr:=store.Write(&hacker{Name: "Alan Turing", Birthyear: 1912}); err!=nil {
panic(err) // handle error
}
varhackers []hacker// Populate hackers slice with ids of all hackers in the storestore.List(&hackers)
alan:=hackers[0]
store.Read(&alan)
fmt.Println("Hello,", alan.Name)
fmt.Println("Listing all", len(hackers), "hackers")
// Fetches all hackers with names from the storestore.ReadMultiple(hackers)
for_, h:=rangehackers {
fmt.Printf("%s (%d) (%s)\n", h.Name, h.Birthyear, h.Id)
}
}
Roadmap
Below are items I am and plan on working on in the near future. Contributions are welcome.
Feature
Status
Save multiple records in a single call using pipelining
implementing
Query (using finders) and indexing
Contributing
Dependency management
Users who import store into their package main are responsible to organize and maintain all of their dependencies to ensure code compatibility and build reproducibility.
Store makes no direct use of dependency management tools like Godep.
We will use a variety of continuous integration providers to find and fix compatibility problems as soon as they occur.