Documentation ¶
Overview ¶
Package datastore - enables data to be persisted in built in datebase (Bolt)
Index ¶
- Variables
- type Backend
- type BoltBackend
- func (bb *BoltBackend) Close() error
- func (bb *BoltBackend) Del(datatype, key string) error
- func (bb *BoltBackend) Get(datatype, key string) (data []byte, err error)
- func (bb *BoltBackend) ListKeys(datatype, index string, skip, limit int, reverse bool) (keys []string, err error)
- func (bb *BoltBackend) Set(datatype, key string, value []byte, indexData map[string]string) error
- type Codec
- type GOBCodec
- type JSONCodec
- type Store
- func (s *Store) Close() error
- func (s *Store) Del(datatype, key string) error
- func (s *Store) Get(datatype, key string, v interface{}) error
- func (s *Store) ListKeys(datatype, index string, skip, limit int, reverse bool) (keys []string, err error)
- func (s *Store) Set(datatype, key string, v interface{}, indexData map[string]string) error
- type StoreOption
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBackendNotInitialized is returned when the backend is not set ErrBackendNotInitialized = errors.New("backend not initialized") // ErrCodecNotInitialized is returned when the codec is not set ErrCodecNotInitialized = errors.New("codec not initialized") // ErrKeyNotFound is returned when an attempt to load a value of a missing key is made ErrKeyNotFound = errors.New("key not found") )
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { Set(datatype, key string, value []byte, indexData map[string]string) error Get(datatype, key string) ([]byte, error) Del(datatype, key string) error ListKeys(datatype, index string, skip, limit int, reverse bool) (keys []string, err error) Close() error }
Backend provides data storage interface
func NewBoltBackend ¶
NewBoltBackend creates a new Bolt backend using CoreOS bbolt implementation
type BoltBackend ¶
type BoltBackend struct {
// contains filtered or unexported fields
}
BoltBackend implements Backend interface with embedded Bolt storage
func (*BoltBackend) Del ¶
func (bb *BoltBackend) Del(datatype, key string) error
Del deletes a key and all the indexes
func (*BoltBackend) Get ¶
func (bb *BoltBackend) Get(datatype, key string) (data []byte, err error)
Get retreives the value for specified key and datatyoe Returns ErrKeyNotFound if the key has no value set
type Codec ¶
type Codec interface { Marshal(v interface{}) ([]byte, error) Unmarshal([]byte, interface{}) error }
Codec probides data serialization interface
type GOBCodec ¶
type GOBCodec struct{}
GOBCodec implement Codec interface with GOB encoding
type JSONCodec ¶
type JSONCodec struct{}
JSONCodec implement Codec interface with JSON encoding
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides key-value data storage with specific backend and codec
func NewStore ¶
func NewStore(options ...StoreOption) (*Store, error)
NewStore constructs a new store
func (*Store) Get ¶
Get retreives the value for specified key and datatyoe Returns ErrKeyNotFound if the key has no value set
type StoreOption ¶
StoreOption sets additional parameters to the Store