Documentation
¶
Index ¶
- Variables
- type BoltDBStore
- func (this *BoltDBStore) AllKeys(bucket []byte) ([][]byte, error)
- func (this *BoltDBStore) Close()
- func (this *BoltDBStore) Count(bucket []byte) uint64
- func (this *BoltDBStore) Delete(bucket, key []byte) error
- func (this *BoltDBStore) Get(bucket, key []byte) ([]byte, error)
- func (this *BoltDBStore) NextSequence(bucket []byte) (uint64, error)
- func (this *BoltDBStore) Open(path string) error
- func (this *BoltDBStore) Put(bucket, key, value []byte) error
- func (this *BoltDBStore) Sequence(bucket []byte) uint64
- func (this *BoltDBStore) SetSequence(bucket []byte, sequence uint64) error
- type KVStore
- type LevelDBStore
- func (this *LevelDBStore) AllKeys(bucket []byte) ([][]byte, error)
- func (this *LevelDBStore) Close()
- func (this *LevelDBStore) Count(bucket []byte) uint64
- func (this *LevelDBStore) Delete(bucket, key []byte) error
- func (this *LevelDBStore) Get(bucket, key []byte) ([]byte, error)
- func (this *LevelDBStore) NextSequence(bucket []byte) (uint64, error)
- func (this *LevelDBStore) Open(path string) error
- func (this *LevelDBStore) Put(bucket, key, value []byte) error
- func (this *LevelDBStore) Sequence(bucket []byte) uint64
- func (this *LevelDBStore) SetSequence(bucket []byte, sequence uint64) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDBClosed = errors.New("kvstore: db closed") ErrKeyNotFound = errors.New("kvstore: key not found") ErrBucketNotFound = errors.New("kvstore: bucket not found") )
View Source
var ( // reserved key for count the number of keys in bucket. KeyForCount = []byte("__key_for_count__") // reserved key for sequence KeyForSequence = []byte("__key_for_sequence__") )
Functions ¶
This section is empty.
Types ¶
type BoltDBStore ¶
type BoltDBStore struct {
// contains filtered or unexported fields
}
func (*BoltDBStore) Close ¶
func (this *BoltDBStore) Close()
func (*BoltDBStore) Count ¶
func (this *BoltDBStore) Count(bucket []byte) uint64
func (*BoltDBStore) Delete ¶
func (this *BoltDBStore) Delete(bucket, key []byte) error
func (*BoltDBStore) NextSequence ¶
func (this *BoltDBStore) NextSequence(bucket []byte) (uint64, error)
func (*BoltDBStore) Open ¶
func (this *BoltDBStore) Open(path string) error
func (*BoltDBStore) Put ¶
func (this *BoltDBStore) Put(bucket, key, value []byte) error
func (*BoltDBStore) Sequence ¶
func (this *BoltDBStore) Sequence(bucket []byte) uint64
func (*BoltDBStore) SetSequence ¶
func (this *BoltDBStore) SetSequence(bucket []byte, sequence uint64) error
type KVStore ¶
type KVStore interface {
// Open database file.
Open(path string) error
// Close database file.
Close()
// Put a key-value pair into the bucket.
// It is safe to modify the contents of the arguments after Put returns but not before.
Put(bucket, key, value []byte) error
// Get the value of this key from bucket.
// The returned slice is its own copy, it is safe to modify the contents of the returned slice.
Get(bucket, key []byte) ([]byte, error)
// Delete the key in bucket.
Delete(bucket, key []byte) error
// Get all keys from bucket.
// // The returned slice is its own copy, it is safe to modify the contents of the returned slice.
AllKeys(bucket []byte) ([][]byte, error)
// Sequence returns the current integer for the bucket without incrementing it.
Sequence(bucket []byte) uint64
// SetSequence updates the sequence number for the bucket.
SetSequence(bucket []byte, sequence uint64) error
// NextSequence returns an autoincrementing integer for the bucket.
NextSequence(bucket []byte) (uint64, error)
// Count return number of key-value pairs in bucket.
Count(bucket []byte) uint64
}
func NewBoltDBStore ¶
func NewBoltDBStore() KVStore
func NewLevelDBStore ¶
func NewLevelDBStore() KVStore
type LevelDBStore ¶
type LevelDBStore struct {
// contains filtered or unexported fields
}
func (*LevelDBStore) Close ¶
func (this *LevelDBStore) Close()
func (*LevelDBStore) Count ¶
func (this *LevelDBStore) Count(bucket []byte) uint64
func (*LevelDBStore) Delete ¶
func (this *LevelDBStore) Delete(bucket, key []byte) error
func (*LevelDBStore) NextSequence ¶
func (this *LevelDBStore) NextSequence(bucket []byte) (uint64, error)
func (*LevelDBStore) Open ¶
func (this *LevelDBStore) Open(path string) error
func (*LevelDBStore) Put ¶
func (this *LevelDBStore) Put(bucket, key, value []byte) error
func (*LevelDBStore) Sequence ¶
func (this *LevelDBStore) Sequence(bucket []byte) uint64
func (*LevelDBStore) SetSequence ¶
func (this *LevelDBStore) SetSequence(bucket []byte, sequence uint64) error
Click to show internal directories.
Click to hide internal directories.