gostore: github.com/twharmon/gostore Index | Examples | Files | Directories

package gostore

import "github.com/twharmon/gostore"

Index

Examples

Package Files

gostore.go header.go int64_db.go int_db.go interface_db.go string_db.go uint64_db.go uint_db.go utils.go

Variables

var ErrKeyTooLarge = errors.New("key is larger than set in config")

ErrKeyTooLarge is returned when the given key is larger than what was set in the config used to open the connection.

var ErrNilValue = errors.New("can not set nil value")

ErrNilValue is returned when the given value is nil.

var ErrValTooLarge = errors.New("value is larger than set in config")

ErrValTooLarge is returned when the given key is larger than what was set in the config used to open the connection.

type Int64DB Uses

type Int64DB struct {
    // contains filtered or unexported fields
}

Int64DB is the data store object.

func OpenInt64DB Uses

func OpenInt64DB(path string, config *Int64DBConfig) (*Int64DB, error)

OpenInt64DB opens a Int64DB stored at path. If the path doesn't exist, an empty store is created at that path.

func (*Int64DB) Clear Uses

func (db *Int64DB) Clear() error

Clear clears the entire data store.

func (*Int64DB) Close Uses

func (db *Int64DB) Close() error

Close closes the connection to the data store and persists the current values to the disk.

func (*Int64DB) Count Uses

func (db *Int64DB) Count() int

Count returns the number of values in the data store.

func (*Int64DB) Delete Uses

func (db *Int64DB) Delete(key string) error

Delete deletes a single item from the data store.

func (*Int64DB) Exists Uses

func (db *Int64DB) Exists(key string) bool

Exists returns whether or not the given key exists.

func (*Int64DB) Get Uses

func (db *Int64DB) Get(key string) int64

Get gets the stored value for the given key.

func (*Int64DB) Keys Uses

func (db *Int64DB) Keys() chan string

Keys returns a channel through which all the keys of the data store will be sent.

func (*Int64DB) Set Uses

func (db *Int64DB) Set(key string, value int64) error

Set saves the given value for the given key.

type Int64DBConfig Uses

type Int64DBConfig struct {
    KeySize int64
}

Int64DBConfig holds configuration information.

type IntDB Uses

type IntDB struct {
    // contains filtered or unexported fields
}

IntDB is the data store object.

func OpenIntDB Uses

func OpenIntDB(path string, config *IntDBConfig) (*IntDB, error)

OpenIntDB opens a IntDB stored at path. If the path doesn't exist, an empty store is created at that path.

func (*IntDB) Clear Uses

func (db *IntDB) Clear() error

Clear clears the entire data store.

func (*IntDB) Close Uses

func (db *IntDB) Close() error

Close closes the connection to the data store and persists the current values to the disk.

func (*IntDB) Count Uses

func (db *IntDB) Count() int

Count returns the number of values in the data store.

func (*IntDB) Delete Uses

func (db *IntDB) Delete(key string) error

Delete deletes a single item from the data store.

func (*IntDB) Exists Uses

func (db *IntDB) Exists(key string) bool

Exists returns whether or not the given key exists.

func (*IntDB) Get Uses

func (db *IntDB) Get(key string) int

Get gets the stored value for the given key.

func (*IntDB) Keys Uses

func (db *IntDB) Keys() chan string

Keys returns a channel through which all the keys of the data store will be sent.

func (*IntDB) Set Uses

func (db *IntDB) Set(key string, value int) error

Set saves the given value for the given key.

type IntDBConfig Uses

type IntDBConfig struct {
    KeySize int64
}

IntDBConfig holds configuration information.

type InterfaceDB Uses

type InterfaceDB struct {
    // contains filtered or unexported fields
}

InterfaceDB is the data store object.

func OpenInterfaceDB Uses

func OpenInterfaceDB(path string, config *InterfaceDBConfig) (*InterfaceDB, error)

OpenInterfaceDB opens a InterfaceDB stored at path. If the path doesn't exist, an empty store is created at that path.

func (*InterfaceDB) Clear Uses

func (db *InterfaceDB) Clear() error

Clear clears the entire data store.

func (*InterfaceDB) Close Uses

func (db *InterfaceDB) Close() error

Close closes the connection to the data store and persists the current values to the disk.

func (*InterfaceDB) Count Uses

func (db *InterfaceDB) Count() int

Count returns the number of values in the data store.

func (*InterfaceDB) Delete Uses

func (db *InterfaceDB) Delete(key string) error

Delete deletes a single item from the data store.

func (*InterfaceDB) Exists Uses

func (db *InterfaceDB) Exists(key string) bool

Exists returns whether or not the given key exists.

func (*InterfaceDB) Keys Uses

func (db *InterfaceDB) Keys() chan string

Keys returns a channel through which all the keys of the data store will be sent.

func (*InterfaceDB) Scan Uses

func (db *InterfaceDB) Scan(key string, value interface{}) error

Scan scans the stored value for the given key.

func (*InterfaceDB) Set Uses

func (db *InterfaceDB) Set(key string, value interface{}) error

Set saves the given value for the given key.

type InterfaceDBConfig Uses

type InterfaceDBConfig struct {
    KeySize int64
    ValSize int64
}

InterfaceDBConfig holds configuration information.

type StringDB Uses

type StringDB struct {
    // contains filtered or unexported fields
}

StringDB is the data store object.

Code:

config := gostore.StringDBConfig{
    KeySize: 8,  // Max Key size in bytes
    ValSize: 8,  // Max Value size in bytes
}
db, _ := gostore.OpenStringDB("/tmp/example.db", &config)
db.Set("foo", "bar")
foo := db.Get("foo")
fmt.Println(foo)

Output:

bar

func OpenStringDB Uses

func OpenStringDB(path string, config *StringDBConfig) (*StringDB, error)

OpenStringDB opens a StringDB stored at path. If the path doesn't exist, an empty store is created at that path.

func (*StringDB) Clear Uses

func (db *StringDB) Clear() error

Clear clears the entire data store.

func (*StringDB) Close Uses

func (db *StringDB) Close() error

Close closes the connection to the data store and persists the current values to the disk.

func (*StringDB) Count Uses

func (db *StringDB) Count() int

Count returns the number of values in the data store.

func (*StringDB) Delete Uses

func (db *StringDB) Delete(key string) error

Delete deletes a single item from the data store.

func (*StringDB) Exists Uses

func (db *StringDB) Exists(key string) bool

Exists returns whether or not the given key exists.

func (*StringDB) Get Uses

func (db *StringDB) Get(key string) string

Get gets the stored value for the given key.

func (*StringDB) Keys Uses

func (db *StringDB) Keys() chan string

Keys returns a channel through which all the keys of the data store will be sent.

Code:

config := gostore.StringDBConfig{
    KeySize: 8,  // Max Key size in bytes
    ValSize: 8,  // Max Value size in bytes
}
db, _ := gostore.OpenStringDB("/tmp/example.db", &config)
db.Set("foo", "bar")
db.Set("bar", "baz")
var keys []string
for key := range db.Keys() {
    keys = append(keys, key)
}
sort.Strings(keys)
fmt.Println(keys)

Output:

[bar foo]

func (*StringDB) Set Uses

func (db *StringDB) Set(key string, value string) error

Set saves the given value for the given key.

type StringDBConfig Uses

type StringDBConfig struct {
    KeySize int64
    ValSize int64
}

StringDBConfig holds configuration information.

type Uint64DB Uses

type Uint64DB struct {
    // contains filtered or unexported fields
}

Uint64DB is the data store object.

func OpenUint64DB Uses

func OpenUint64DB(path string, config *Uint64DBConfig) (*Uint64DB, error)

OpenUint64DB opens a Uint64DB stored at path. If the path doesn't exist, an empty store is created at that path.

func (*Uint64DB) Clear Uses

func (db *Uint64DB) Clear() error

Clear clears the entire data store.

func (*Uint64DB) Close Uses

func (db *Uint64DB) Close() error

Close closes the connection to the data store and persists the current values to the disk.

func (*Uint64DB) Count Uses

func (db *Uint64DB) Count() int

Count returns the number of values in the data store.

func (*Uint64DB) Delete Uses

func (db *Uint64DB) Delete(key string) error

Delete deletes a single item from the data store.

func (*Uint64DB) Exists Uses

func (db *Uint64DB) Exists(key string) bool

Exists returns whether or not the given key exists.

func (*Uint64DB) Get Uses

func (db *Uint64DB) Get(key string) uint64

Get gets the stored value for the given key.

func (*Uint64DB) Keys Uses

func (db *Uint64DB) Keys() chan string

Keys returns a channel through which all the keys of the data store will be sent.

func (*Uint64DB) Set Uses

func (db *Uint64DB) Set(key string, value uint64) error

Set saves the given value for the given key.

type Uint64DBConfig Uses

type Uint64DBConfig struct {
    KeySize int64
}

Uint64DBConfig holds configuration information.

type UintDB Uses

type UintDB struct {
    // contains filtered or unexported fields
}

UintDB is the data store object.

func OpenUintDB Uses

func OpenUintDB(path string, config *UintDBConfig) (*UintDB, error)

OpenUintDB opens a UintDB stored at path. If the path doesn't exist, an empty store is created at that path.

func (*UintDB) Clear Uses

func (db *UintDB) Clear() error

Clear clears the entire data store.

func (*UintDB) Close Uses

func (db *UintDB) Close() error

Close closes the connection to the data store and persists the current values to the disk.

func (*UintDB) Count Uses

func (db *UintDB) Count() int

Count returns the number of values in the data store.

func (*UintDB) Delete Uses

func (db *UintDB) Delete(key string) error

Delete deletes a single item from the data store.

func (*UintDB) Exists Uses

func (db *UintDB) Exists(key string) bool

Exists returns whether or not the given key exists.

func (*UintDB) Get Uses

func (db *UintDB) Get(key string) uint

Get gets the stored value for the given key.

func (*UintDB) Keys Uses

func (db *UintDB) Keys() chan string

Keys returns a channel through which all the keys of the data store will be sent.

func (*UintDB) Set Uses

func (db *UintDB) Set(key string, value uint) error

Set saves the given value for the given key.

type UintDBConfig Uses

type UintDBConfig struct {
    KeySize int64
}

UintDBConfig holds configuration information.

Directories

PathSynopsis
wal

Package gostore imports 9 packages (graph). Updated 2020-02-17. Refresh now. Tools for package owners.