store

package
v0.0.0-...-fae07df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound indicates object is not in database.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	NewEncoder(io.Writer) Encoder
	NewDecoder(io.Reader) Decoder
}

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 JSONCodec

type JSONCodec struct{}

JSONCodec is used to encode/decode JSON

func (JSONCodec) NewDecoder

func (c JSONCodec) NewDecoder(r io.Reader) Decoder

NewDecoder returns a new json decoder which reads from r

func (JSONCodec) NewEncoder

func (c JSONCodec) NewEncoder(w io.Writer) Encoder

NewEncoder retuns a new json encoder which writes to w

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store manages objects persistance.

func NewCustomStore

func NewCustomStore(db *bolt.DB, bucket []byte, codec Codec) *Store

NewCustomStore allows you to create a store with a custom underlying Encoding

func NewJSONStore

func NewJSONStore(db *bolt.DB, bucket []byte) *Store

NewJSONStore creates a new Store, using the underlying bolt.DB "bucket" to persist objects as json.

func NewStore

func NewStore(db *bolt.DB, bucket []byte) *Store

NewStore creates a new Store, using the underlying bolt.DB "bucket" to persist objects. NewStore uses JSONEncoding to encode objects

func NewXMLStore

func NewXMLStore(db *bolt.DB, bucket []byte) *Store

NewXMLStore creates a new Store, using the underlying bolt.DB "bucket" to persist objects as xml.

func (*Store) DeleteAll

func (s *Store) DeleteAll() error

DeleteAll empties the store

func (*Store) ForEach

func (s *Store) ForEach(do interface{}) error

ForEach will run do on each object in the store. do must be a function which takes exactly one parameter, which is decodeable.

func (*Store) Get

func (s *Store) Get(key []byte, b interface{}) error

Get will retreive b with key "key"

func (*Store) Pull

func (s *Store) Pull(key []byte, b interface{}) error

Pull will retreive b with key "key", and removes it from the store.

func (*Store) Put

func (s *Store) Put(key []byte, b interface{}) error

Put will store b with key "key"

type XMLCodec

type XMLCodec struct{}

XMLCodec is used to encode/decode XML

func (XMLCodec) NewDecoder

func (c XMLCodec) NewDecoder(r io.Reader) Decoder

NewDecoder returns a new xml decoder which reads from r

func (XMLCodec) NewEncoder

func (c XMLCodec) NewEncoder(w io.Writer) Encoder

NewEncoder returns a new xml encoder which writes to w

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL