Documentation ¶
Index ¶
- Constants
- Variables
- func IsErrNotFound(err error) bool
- func IsErrOpNotSupported(err error) bool
- type DB
- type Entry
- type NotSupportedDB
- func (*NotSupportedDB) Close() error
- func (*NotSupportedDB) CmpAndSwap(bucket, key, oldValue, newValue []byte) ([]byte, bool, error)
- func (*NotSupportedDB) CreateTable(bucket []byte) error
- func (*NotSupportedDB) Del(bucket, key []byte) error
- func (*NotSupportedDB) DeleteTable(bucket []byte) error
- func (*NotSupportedDB) Get(bucket, key []byte) (ret []byte, err error)
- func (*NotSupportedDB) List(bucket []byte) ([]*Entry, error)
- func (*NotSupportedDB) Open(dataSourceName string, opt ...Option) error
- func (*NotSupportedDB) Set(bucket, key, value []byte) error
- func (*NotSupportedDB) Update(tx *Tx) error
- type Option
- type Options
- type Tx
- type TxCmd
- type TxEntry
Constants ¶
const ( BadgerMemoryMap = "mmap" BadgerFileIO = "fileio" )
Badger FileLoadingMode constants.
Variables ¶
var ( // ErrNotFound is the type returned on DB implementations if an item does not // exist. ErrNotFound = errors.New("not found") // ErrOpNotSupported is the type returned on DB implementations if an operation // is not supported. ErrOpNotSupported = errors.New("operation not supported") )
Functions ¶
func IsErrNotFound ¶
IsErrNotFound returns true if the cause of the given error is ErrNotFound.
func IsErrOpNotSupported ¶
IsErrOpNotSupported returns true if the cause of the given error is ErrOpNotSupported.
Types ¶
type DB ¶
type DB interface { // Open opens the database available with the given options. Open(dataSourceName string, opt ...Option) error // Close closes the current database. Close() error // Get returns the value stored in the given table/bucket and key. Get(bucket, key []byte) (ret []byte, err error) // Set sets the given value in the given table/bucket and key. Set(bucket, key, value []byte) error // CmpAndSwap swaps the value at the given bucket and key if the current // value is equivalent to the oldValue input. Returns 'true' if the // swap was successful and 'false' otherwise. CmpAndSwap(bucket, key, oldValue, newValue []byte) ([]byte, bool, error) // Del deletes the data in the given table/bucket and key. Del(bucket, key []byte) error // List returns a list of all the entries in a given table/bucket. List(bucket []byte) ([]*Entry, error) // Update performs a transaction with multiple read-write commands. Update(tx *Tx) error // CreateTable creates a table or a bucket in the database. CreateTable(bucket []byte) error // DeleteTable deletes a table or a bucket in the database. DeleteTable(bucket []byte) error }
DB is a interface to be implemented by the databases.
type NotSupportedDB ¶ added in v0.4.0
type NotSupportedDB struct{}
NotSupportedDB is a db implementation used on database drivers when the no<driver> tags are used.
func (*NotSupportedDB) Close ¶ added in v0.4.0
func (*NotSupportedDB) Close() error
func (*NotSupportedDB) CmpAndSwap ¶ added in v0.4.0
func (*NotSupportedDB) CmpAndSwap(bucket, key, oldValue, newValue []byte) ([]byte, bool, error)
func (*NotSupportedDB) CreateTable ¶ added in v0.4.0
func (*NotSupportedDB) CreateTable(bucket []byte) error
func (*NotSupportedDB) Del ¶ added in v0.4.0
func (*NotSupportedDB) Del(bucket, key []byte) error
func (*NotSupportedDB) DeleteTable ¶ added in v0.4.0
func (*NotSupportedDB) DeleteTable(bucket []byte) error
func (*NotSupportedDB) Get ¶ added in v0.4.0
func (*NotSupportedDB) Get(bucket, key []byte) (ret []byte, err error)
func (*NotSupportedDB) List ¶ added in v0.4.0
func (*NotSupportedDB) List(bucket []byte) ([]*Entry, error)
func (*NotSupportedDB) Open ¶ added in v0.4.0
func (*NotSupportedDB) Open(dataSourceName string, opt ...Option) error
func (*NotSupportedDB) Set ¶ added in v0.4.0
func (*NotSupportedDB) Set(bucket, key, value []byte) error
func (*NotSupportedDB) Update ¶ added in v0.4.0
func (*NotSupportedDB) Update(tx *Tx) error
type Option ¶
Option is the modifier type over Options.
func WithBadgerFileLoadingMode ¶ added in v0.3.0
WithBadgerFileLoadingMode is a modifier that sets the ValueLogLoadingMode of Badger db.
func WithDatabase ¶
WithDatabase is a modifier that sets the Database attribute of Options.
func WithValueDir ¶
WithValueDir is a modifier that sets the ValueDir attribute of Options.
type Tx ¶
type Tx struct {
Operations []*TxEntry
}
Tx represents a transaction and it's list of multiple TxEntry. Each TxEntry represents a read or write operation on the database.
func (*Tx) CreateTable ¶
CreateTable adds a new create query to the transaction.
func (*Tx) DeleteTable ¶
DeleteTable adds a new create query to the transaction.
type TxCmd ¶
type TxCmd int
TxCmd is the type used to represent database command and operations.
const ( // CreateTable on a TxEntry will represent the creation of a table or // bucket on the database. CreateTable TxCmd = iota // DeleteTable on a TxEntry will represent the deletion of a table or // bucket on the database. DeleteTable // Get on a TxEntry will represent a command to retrieve data from the // database. Get // Set on a TxEntry will represent a command to write data on the // database. Set // Delete on a TxEntry represent a command to delete data on the database. Delete // CmpAndSwap on a TxEntry will represent a compare and swap operation on // the database. It will compare the value read and change it if it's // different. The TxEntry will contain the value read. CmpAndSwap // CmpOrRollback on a TxEntry will represent a read transaction that will // compare the values will the ones passed, and if they don't match the // transaction will fail CmpOrRollback )