Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned when the key supplied to a Get or Delete // method does not exist in the database. ErrNotFound = errors.New("db: key not found") // ErrBadValue is returned when the value supplied to the Put method is nil. ErrBadValue = errors.New("db: bad value") )
Functions ¶
func KeystoreLocation ¶
func KeystoreLocation() string
KeystoreLocation returns the file path to store the DB for individual users. This will be ~/.hpe/store.db
Types ¶
type StorageEngine ¶
type StorageEngine int
StorageEngine defines the backend storage engine to be used This ostensibly allows different backends to be used. e.g. if we want to switch to a json based file
const ( // SKV is Simple Key Value store from: github.com/rapidloop/skv SKV StorageEngine = iota )
type Store ¶
type Store interface { // Get an entry from the store. "value" must be a pointer-typed. If the key // is not present in the store, Get returns ErrNotFound. // // type MyStruct struct { // Numbers []int // } // var val MyStruct // if err := store.Get("key42", &val); err == store.ErrNotFound { // // "key42" not found // } else if err != nil { // // an error occurred // } else { // // ok // } // // The value passed to Get() can be nil, in which case any value read from // the store is silently discarded. // // if err := store.Get("key42", nil); err == nil { // fmt.Println("entry is present") // } Get(key string, value interface{}) error // Put an entry into the store. The passed value is gob-encoded and stored. // The key can be an empty string, but the value cannot be nil - if it is, // Put() returns ErrBadValue. // // err := store.Put("key42", 156) // err := store.Put("key42", "this is a string") // m := map[string]int{ // "harry": 100, // "emma": 101, // } // err := store.Put("key43", m) Put(key string, value interface{}) error // Delete the entry with the given key. If no such key is present in the store, // it returns ErrNotFound. // // store.Delete("key42") Delete(key string) error // Close closes the key-value store file. Close() error }
Store is the interface to store persistent data This allows for changing backend storage engines
func NewStore ¶
func NewStore(se StorageEngine) (Store, error)
NewStore returns a handle to a store. Currently there is a single backend - so you can use DefautlStore instead of this method
Click to show internal directories.
Click to hide internal directories.