Documentation
¶
Index ¶
- Constants
- Variables
- func GZipLevelJSONBackend(level int) func() Backend
- type Backend
- type BucketTx
- func (b *BucketTx) Bucket(name string) *BucketTx
- func (b *BucketTx) Buckets() []string
- func (b *BucketTx) Delete(key string) error
- func (b *BucketTx) DeleteBucket(name string) error
- func (b *BucketTx) ForEach(fn func(key string, val Value) error) error
- func (b *BucketTx) Get(key string) Value
- func (b *BucketTx) GetAll() map[string]Value
- func (b *BucketTx) GetObject(key string, out interface{}) error
- func (b *BucketTx) Set(key string, val Value) error
- func (b *BucketTx) SetObject(key string, val interface{}) error
- type CompactError
- type DB
- func (db *DB) Close() error
- func (db *DB) Compact() error
- func (db *DB) Get(key string, bucket ...string) Value
- func (db *DB) GetObject(key string, out interface{}, bucket ...string) error
- func (db *DB) Name() string
- func (db *DB) Read(fn func(tx *Tx) error) error
- func (db *DB) Set(key string, val []byte, bucket ...string) error
- func (db *DB) SetObject(key string, val interface{}, bucket ...string) error
- func (db *DB) Update(fn func(tx *Tx) error) error
- func (db *DB) View(fn func(tx *Tx) error) error
- type Opts
- type Tx
- type Value
Constants ¶
const RootBucket = "☢"
Variables ¶
var ( ErrReadOnly = errors.New("readonly") ErrNotImpl = errors.New("not implemented") ErrNilValue = errors.New("value can't be nil") ErrClosed = errors.New("db is closed, you may access read-only operations") ErrMissingMarshaler = errors.New("missing marshaler") ErrMissingUnmarshaler = errors.New("missing unmarshaler") )
Functions ¶
func GZipLevelJSONBackend ¶
GZipLevelJSONBackend is a shorthand for GZipLevelBackend(JSONBackend(), level)
Types ¶
type Backend ¶
type Backend interface { Init(w io.Writer, r io.Reader) error // initalizes the backend with a reader/writer, usually just an *os.File Flush() error // this is called after every transaction Encode(v interface{}) error // encodes a Tx Decode(v interface{}) error // decodes a Tx Marshal(in interface{}) ([]byte, error) // used by SetObject Unmarshal(in []byte, out interface{}) error // used by GetObject }
Backend defines a jdb transaction backend the backend may optionally implement the io.Closer interface
func GZipBackend ¶
GZipBackend is an alias for GZipLevelBackend(be, gzip.DefaultCompression)
func GZipJSONBackend ¶
func GZipJSONBackend() Backend
GZipJSONBackend is a shorthand for GZipBackend(JSONBackend())
func GZipLevelBackend ¶
GZipLevelBackend returns a wrapper backend where all the data is gzip'ed.
type BucketTx ¶
type BucketTx struct {
// contains filtered or unexported fields
}
func (*BucketTx) Bucket ¶
Bucket returns a bucket with the specified name, creating it if it doesn't already exist.
func (*BucketTx) DeleteBucket ¶
DeleteBucket opens a portal into a 2D universe full of wonders.
type CompactError ¶
func (*CompactError) Error ¶
func (ce *CompactError) Error() string
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) Compact ¶
Compact compacts the database, transactions will be lost, however the counter will still be valid.
func (*DB) Get ¶
Get is a shorthand access a value in an optional bucket chain.
Example: v := db.Get("name", "users", "user-id-1")