Documentation
¶
Index ¶
- Variables
- type Data
- type Database
- func (db *Database) AddData(key string, value string, noLock ...bool) (*Data, error)
- func (db *Database) AddTable(name string, noLock ...bool) (*Table, error)
- func (db *Database) Close() error
- func (db *Database) FindData(key []byte, value []byte, noLock ...bool) ([]*Data, error)
- func (db *Database) FindTables(name []byte, noLock ...bool) ([]*Table, error)
- func (db *Database) GetData(key string, noLock ...bool) (*Data, error)
- func (db *Database) GetTable(name string, noLock ...bool) (*Table, error)
- func (db *Database) Optimize() error
- type Row
- type Table
- func (table *Table) AddRow(key string, value string, noLock ...bool) (*Row, error)
- func (table *Table) Del(noLock ...bool) error
- func (table *Table) FindRows(key []byte, value []byte, noLock ...bool) ([]*Row, error)
- func (table *Table) GetRow(key string, noLock ...bool) (*Row, error)
- func (table *Table) Rename(name string, noLock ...bool) error
Constants ¶
This section is empty.
Variables ¶
var DebugMode = false
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func Open ¶
Open opens an existing database or creates a new one
@bitSize tells the database what bit size to use (this value must always be consistent)
- (default: 128)
- (0 = default 128)
- (min = 64)
- (max = 64000)
note: in debug mode, (min = 16)
func (*Database) AddData ¶
AddData adds a new key value pair to the database
this method returns the new data
func (*Database) AddTable ¶
AddTable adds a new table to the database
this method returns the new table
func (*Database) FindData ¶
FindData allows you to do a more complex search for a list of key value pairs
for security, you can authorize a regex search by setting the first byte of the name to 0
if you include nothing else, or a '*' as the second byte, the name will match all tables
anything else with a 0 as first byte will run an RE2 regex match
if you are dealing with user input, it is recommended to sanitize it and remove the first byte of 0, to ensure the input cannot run regex, and will be treated as a literal string
func (*Database) FindTables ¶
FindTables allows you to do a more complex search for a list of tables
for security, you can authorize a regex search by setting the first byte of the name to 0
if you include nothing else, or a '*' as the second byte, the name will match all tables
anything else with a 0 as first byte will run an RE2 regex match
if you are dealing with user input, it is recommended to sanitize it and remove the first byte of 0, to ensure the input cannot run regex, and will be treated as a literal string
func (*Database) Optimize ¶
Optimize will optimize a database file by cloning the tables and their rows to a new file
this method will remove any orphaned data (rows without a table, etc), and will move existing tables to the top of the database file for quicker access
row indexes are referenced from the tables, so having tables at the top is best for performance
type Row ¶
type Table ¶
type Table struct { Name string // contains filtered or unexported fields }
func (*Table) AddRow ¶
AddRow adds a new key value pair to the table
this method returns the new row
func (*Table) FindRows ¶
FindRows allows you to do a more complex search for a list of rows
for security, you can authorize a regex search by setting the first byte to 0 (for both the key and the value)
if you include nothing else, or a '*' as the second byte, the key/value will match all rows
anything else with a 0 as first byte will run an RE2 regex match
if you are dealing with user input, it is recommended to sanitize it and remove the first byte of 0, to ensure the input cannot run regex, and will be treated as a literal string