Documentation ¶
Index ¶
- Constants
- Variables
- type Bucket
- type DB
- func (d *DB) Bucket(name string) *Bucket
- func (d *DB) Close() error
- func (d *DB) Delete(key string) error
- func (d *DB) DeleteNotBelonging(doesntBelong func(string) bool) error
- func (d *DB) DeleteReplicationKey(key, val []byte) error
- func (d *DB) Get(key string) ([]byte, error)
- func (d *DB) GetLevelDB() *leveldb.DB
- func (d *DB) GetNextReplica() (key, value []byte, err error)
- func (d *DB) Set(key string, value []byte) error
- func (d *DB) SetOnReplica(key string, val []byte) error
Constants ¶
const MaxBuckets = math.MaxUint16 - (8 * 256)
MaxBuckets is the maximum amount of buckets
Variables ¶
var ( // ErrReadOnly happens when a someone tries to write into the database when it is read-only mode. ErrReadOnly = errors.New("cannot make changes to database, since it is in read-only mode") // ErrKeyLength happens when creating a key which length is 0, such that appending a bucket prefix // would be quite dumb. ErrKeyLength = errors.New("the key length cannot be 0") // ErrNotFound happens when a wanted key-value pair doesn't exist. ErrNotFound = errors.New("the key was not found") // ErrBucketName happens when the wanted bucket name is too short. ErrBucketName = errors.New("the bucket name is too short") // ErrValDontMatch happens when deleting a key from the replication bucket. This means that // that the key-value pair which the user wants to delete is already out-of-date and thus shouldn't // be deleted. ErrValDontMatch = errors.New("values don't match") )
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket is a collection of records in the database
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents the database
func NewDatabase ¶
NewDatabase returns a new instance of a database
func (*DB) Bucket ¶
Bucket is the common method for doing operations on a bucket for example: d.Bucket(defaultBucket).Get(key)
func (*DB) DeleteNotBelonging ¶
DeleteNotBelonging deletes all the key-value pairs in which the key matches the doesntBelong function.
func (*DB) DeleteReplicationKey ¶
DeleteReplicationKey deletes the key from the replication queue.
func (*DB) GetLevelDB ¶
GetLevelDB returns a pointer to the underlying levelDB database this is mostly used for testing if buckets really insert into buckets
func (*DB) GetNextReplica ¶
GetNextReplica returns the key-value pair that has changed and has not yet applied to replicas.