Documentation
¶
Index ¶
- Constants
- Variables
- func PsqlCreateKV(db *sqlx.DB, table string) error
- func PsqlCreateKVMissing(db *sqlx.DB, table string) error
- func PsqlCreateTable(db *sqlx.DB, table, scheme string) error
- func PsqlCreateTableMissing(db *sqlx.DB, table, scheme string) error
- func PsqlDrop(db *sqlx.DB, table string) error
- func PsqlDropExist(db *sqlx.DB, table string) error
- func Sqlite3CreateKV(db *sqlx.DB, table string) error
- func Sqlite3CreateKVMissing(db *sqlx.DB, table string) error
- func Sqlite3CreateTable(db *sqlx.DB, table, scheme string) error
- func Sqlite3CreateTableMissing(db *sqlx.DB, table, scheme string) error
- func Sqlite3Drop(db *sqlx.DB, table string) error
- func Sqlite3DropExist(db *sqlx.DB, table string) error
- type Iter
- type KV
- func (b *KV) Add(k string, v interface{}) error
- func (b *KV) AddClass(k, cls string, v interface{}) error
- func (b *KV) AppendBytes(k string, bs []byte) error
- func (b *KV) Clear() error
- func (b *KV) Count() (int64, error)
- func (b *KV) Create() error
- func (b *KV) CreateMissing() error
- func (b *KV) Destroy() error
- func (b *KV) Emplace(k string, v interface{}) error
- func (b *KV) Get(k string, v interface{}) error
- func (b *KV) GetBytes(k string) ([]byte, error)
- func (b *KV) Has(k string) (bool, error)
- func (b *KV) Mutate(k string, v interface{}, f func(v interface{}) error) error
- func (b *KV) Remove(k string) error
- func (b *KV) Replace(k string, v interface{}) error
- func (b *KV) Set(k string, v interface{}) error
- func (b *KV) SetBytes(k string, bs []byte) error
- func (b *KV) SetClass(k, cls string) error
- func (b *KV) Walk(it *Iter) error
- func (b *KV) WalkClass(cls string, it *Iter) error
- func (b *KV) WalkPartial(p *KVPartial, it *Iter) error
- func (b *KV) WalkPartialClass(cls string, p *KVPartial, it *Iter) error
- type KVOps
- type KVPartial
- type Table
- type Tables
- type WalkFunc
Constants ¶
const MaxKVClassLen = 255
MaxKVClassLen is the maximum length of the class string of a hashed KV.
const MaxKVKeyLen = 255
MaxKVKeyLen is the maximum key length of ordered key-value pair storage.
const MaxKeyLen = 255
MaxKeyLen is the maximum length of a hashed KV.
Variables ¶
var ErrCancel = errors.New("operation cancelled")
ErrCancel is the error when the operation is canclled.
var ErrUnordered = errors.New("the index is unordered")
ErrUnordered is the error when an ordered table operation is operated on an unordered table.
Functions ¶
func PsqlCreateKV ¶
PsqlCreateKV creates a key value pair postgres table.
func PsqlCreateKVMissing ¶
PsqlCreateKVMissing creates a key value pair postgres table if the table does not exist.
func PsqlCreateTable ¶
PsqlCreateTable creates a postgres table for the given table name and scheme.
func PsqlCreateTableMissing ¶
PsqlCreateTableMissing creates a postgres table if it does not exist, using the given table name and scheme.
func PsqlDropExist ¶
PsqlDropExist destroys the table if the table exists. It does nothing if the table does not exist.
func Sqlite3CreateKV ¶
Sqlite3CreateKV creates a key value pair sqlite3 table.
func Sqlite3CreateKVMissing ¶
Sqlite3CreateKVMissing creates a key value pair sqlite3 table if the table does not exist.
func Sqlite3CreateTable ¶
Sqlite3CreateTable creates a table for the given table for the given table name and scheme.
func Sqlite3CreateTableMissing ¶
Sqlite3CreateTableMissing creates a postgres table if it does not exist, using the given table name and scheme.
func Sqlite3Drop ¶
Sqlite3Drop destroys the specific sqlite3 table.
Types ¶
type KV ¶
type KV struct {
// contains filtered or unexported fields
}
KV provides a key-value pair table.
func NewOrderedMemKV ¶
func NewOrderedMemKV() *KV
NewOrderedMemKV creates a new ordered key-value pair in memory.
func NewOrderedPsqlKV ¶
NewOrderedPsqlKV creates a new postgresql backed ordered key-value pair storage.
func NewOrderedSqlite3KV ¶
NewOrderedSqlite3KV creates a new sqlite3 backed ordered key-value pair storage.
func NewSqlite3KV ¶
NewSqlite3KV creates a new sqlite3 backed unordered key-value pair storage.
func (*KV) AppendBytes ¶
AppendBytes appends the byte slice to the existing value of the entry of the specified key. Creates the key if not exist.
func (*KV) CreateMissing ¶
CreateMissing creates the table if the table is missing.
func (*KV) Emplace ¶
Emplace sets the value for a particular key. Does nothing if the key already exists.
func (*KV) WalkClass ¶
WalkClass iterates through all entries in the key-value store of a particular class.
func (*KV) WalkPartial ¶
WalkPartial iterates through a part of the entries in the key-value store, specificed by the partial option.
type KVOps ¶
type KVOps struct { Clear func() error Add func(key, cls string, bs []byte) error Get func(key string) ([]byte, error) Has func(key string) (bool, error) Set func(key string, bs []byte) error SetClass func(key, cls string) error Mutate func(key string, f func(bs []byte) ([]byte, error)) error Remove func(key string) error Emplace func(key, cls string, bs []byte) error Replace func(key, cls string, bs []byte) error Append func(key string, bs []byte) error Walk func(f WalkFunc) error WalkClass func(cls string, f WalkFunc) error WalkPartial func(p *KVPartial, f WalkFunc) error WalkPartialClass func(cls string, p *KVPartial, f WalkFunc) error Count func() (int64, error) Create func() error CreateMissing func() error Destroy func() error }
KVOps provides operations to operate over an unordered key-value pair table.
type Table ¶
type Table interface { // Create creates table. Create() error // CreateMissing creates the table if it is missing. CreateMissing() error // Destroy destroys the table. Destroy() error }
Table contains common operations for creating and destroying a table.
type Tables ¶
type Tables struct {
// contains filtered or unexported fields
}
Tables saves a set of psql tables that are backed by a postgres database backend, or backed by memory.
func NewMemTables ¶
func NewMemTables() *Tables
NewMemTables creates a new table set that reside entirely inside memory.
func NewTables ¶
NewTables creates a new table set using the given database backend. When db is nil, it uses memory.
func OpenPsqlTables ¶
OpenPsqlTables dials into a postgresql connection and creates PsqlTables with it.
func OpenSqlite3Tables ¶
OpenSqlite3Tables opens a sqlite3 database using the given file.
func (*Tables) CreateMissing ¶
CreateMissing creates all missing tables.
func (*Tables) NewOrderedKV ¶
NewOrderedKV creates an ordered key-value pair table.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package settings provides a generic, simple key-value pair like interface for saving application settings.
|
Package settings provides a generic, simple key-value pair like interface for saving application settings. |