Documentation ¶
Overview ¶
Package stow is used to persist objects to a bolt.DB database.
Index ¶
- Variables
- func Register(value interface{})
- func RegisterName(name string, value interface{})
- type Codec
- type Decoder
- type Encoder
- type GobCodec
- type JSONCodec
- type Store
- func (s *Store) DeleteAll() error
- func (s *Store) ForEach(do interface{}) error
- func (s *Store) Get(key []byte, b interface{}) error
- func (s *Store) GetKey(key interface{}, b interface{}) error
- func (s *Store) Pull(key []byte, b interface{}) error
- func (s *Store) PullKey(key interface{}, b interface{}) error
- func (s *Store) Put(key []byte, b interface{}) (err error)
- func (s *Store) PutKey(key interface{}, b interface{}) error
- type XMLCodec
Constants ¶
This section is empty.
Variables ¶
ErrNotFound indicates object is not in database.
Functions ¶
func Register ¶
func Register(value interface{})
Register registers the type using gob.Register for use with NewStore() and the GobCodec.
Types ¶
type Codec ¶
Codec provides a mechanism for storing/retriving objects as streams of data.
type Decoder ¶
type Decoder interface {
Decode(interface{}) error
}
Decoder is used to decode objects
type Encoder ¶
type Encoder interface {
Encode(interface{}) error
}
Encoder is used to encode objects
type GobCodec ¶
type GobCodec struct{}
GobCodec is used to encode/decode using the Gob format.
func (GobCodec) NewDecoder ¶
NewDecoder returns a new gob decoder which reads from r
type JSONCodec ¶
type JSONCodec struct{}
JSONCodec is used to encode/decode JSON
func (JSONCodec) NewDecoder ¶
NewDecoder returns a new json decoder which reads from r
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages objects persistance.
func NewCustomStore ¶
NewCustomStore allows you to create a store with a custom underlying Encoding
func NewJSONStore ¶
NewJSONStore creates a new Store, using the underlying bolt.DB "bucket" to persist objects as json.
func NewStore ¶
NewStore creates a new Store, using the underlying bolt.DB "bucket" to persist objects. NewStore uses GobEncoding, your objects must be registered via gob.Register() for this encoding to work.
func NewXMLStore ¶
NewXMLStore creates a new Store, using the underlying bolt.DB "bucket" to persist objects as xml.
func (*Store) ForEach ¶
ForEach will run do on each object in the store. do can be a function which takes either: 1 param which will take on each "value" or 2 params where the first param is the "key" and the second is the "value".
func (*Store) Get ¶
Get will retreive b with key "key"
func (*Store) GetKey ¶ added in v1.1.0
GetKey will retreive b with key "key". If key is []byte or string it uses the key directly. Otherwise, it marshals the given type into bytes using the stores Encoder.
func (*Store) Pull ¶
Pull will retreive b with key "key", and removes it from the store.
func (*Store) PullKey ¶ added in v1.1.0
PullKey will retreive b with key "key", and removes it from the store.
func (*Store) Put ¶
Put will store b with key "key". If key is []byte or string it uses the key directly. Otherwise, it marshals the given type into bytes using the stores Encoder.