Documentation
¶
Overview ¶
inidb package uses a regular ini file as a database. Ini sections are considered tables. Individual entries are considered records and are key = value pairs.
The package assumes that the user will create a single inidb per directory.
Index ¶
- Variables
- type INIDB
- func (i *INIDB) Del(table, key string) error
- func (i *INIDB) DelTable(table string) error
- func (i *INIDB) Get(table string, key string) (string, error)
- func (i *INIDB) NewTable(table string)
- func (i *INIDB) Records(table string) map[string]string
- func (i *INIDB) Save() error
- func (i *INIDB) Set(table, key, value string) error
- func (i *INIDB) Tables() []string
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("record not found") ErrCreated = errors.New("database created") )
Functions ¶
This section is empty.
Types ¶
type INIDB ¶
type INIDB struct {
// contains filtered or unexported fields
}
INIDB is an opaque structure that contains the database context.
func New ¶
New returns a new INIDB context. Depth contains the maximum number of files that are retained. Create indicates if the database should be created if it doesn't exist. If depth is negative there is no limit. If the ini file does not exist it returns an error. The inidb package assumes there is only one inidb per directory. DO NOT CREATE MULTIPLE INIDBS IN A SINGLE DIRECTORY.
func (*INIDB) Get ¶
Get returns a record from table. If the record does not exist ErrNotFound is returned.
func (*INIDB) Save ¶
Save flushes current in memory database back to disk. The process is as follows:
- Check if the database is dirty and abort process if it isn't
- Create temporary file that contains all memory tables and records
- Backup original file
- Rename temporary file to the original file name
This creates a running log of flushes.
NOTE: currently there is no file count limiter.