kvstore

package
v0.0.0-...-83e654d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KVStore

type KVStore interface {

	// Put stores an entry in the key-value store
	Put(schema, key string, value []byte) error

	// Get fetches one entry
	Get(schema, key string) (value []byte, exist bool, err error)

	// Delete an entry
	Delete(schema, key string) error

	// Iterate iterates over all entries in the key value store.
	// The result will be sent to the channel, which is closed after the last entry.
	// For simplicity, the return type is an string array with key, value.
	// If you have binary values, you can safely cast back to []byte.
	Iterate(schema, keyPrefix string) (entries chan [2]string)

	// IterateKeys iterates over all keys in the key value store.
	// The keys will be sent to the channel, which is closed after the last entry.
	IterateKeys(schema, keyPrefix string) (keys chan string)
}

KVStore is an interface for a persistence backend, storing key-value pairs.

type MemoryKVStore

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

MemoryKVStore is a struct representing an in-memory key-value store.

func NewMemoryKVStore

func NewMemoryKVStore() *MemoryKVStore

NewMemoryKVStore returns a new configured MemoryKVStore.

func (*MemoryKVStore) Delete

func (kvStore *MemoryKVStore) Delete(schema, key string) error

Delete implements the `kvstore` Delete func.

func (*MemoryKVStore) Get

func (kvStore *MemoryKVStore) Get(schema, key string) ([]byte, bool, error)

Get implements the `kvstore` Get func.

func (*MemoryKVStore) Iterate

func (kvStore *MemoryKVStore) Iterate(schema string, keyPrefix string) chan [2]string

Iterate iterates over the key-value pairs in the schema, with keys matching the keyPrefix. TODO: this can lead to a deadlock, if the consumer modifies the store while receiving and the channel blocks

func (*MemoryKVStore) IterateKeys

func (kvStore *MemoryKVStore) IterateKeys(schema string, keyPrefix string) chan string

IterateKeys iterates over the keys in the schema, matching the keyPrefix. TODO: this can lead to a deadlock, if the consumer modifies the store while receiving and the channel blocks

func (*MemoryKVStore) Put

func (kvStore *MemoryKVStore) Put(schema, key string, value []byte) error

Put implements the `kvstore` Put func.

type PostgresConfig

type PostgresConfig struct {
	ConnParams   map[string]string
	MaxIdleConns int
	MaxOpenConns int
}

PostgresConfig is a map-based configuration of a Postgresql connection (dbname, host etc.), extended with gorm-specific parameters (e.g. number of open / idle connections).

type PostgresKVStore

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

PostgresKVStore extends a gorm-based kvStore with a Postgresql-specific configuration.

func NewPostgresKVStore

func NewPostgresKVStore(postgresConfig PostgresConfig) *PostgresKVStore

NewPostgresKVStore returns a new configured PostgresKVStore (not opened yet).

func (PostgresKVStore) Check

func (store PostgresKVStore) Check() error

func (PostgresKVStore) Delete

func (store PostgresKVStore) Delete(schema, key string) error

func (PostgresKVStore) Get

func (store PostgresKVStore) Get(schema, key string) ([]byte, bool, error)

func (PostgresKVStore) Iterate

func (store PostgresKVStore) Iterate(schema string, keyPrefix string) chan [2]string

func (PostgresKVStore) IterateKeys

func (store PostgresKVStore) IterateKeys(schema string, keyPrefix string) chan string

func (*PostgresKVStore) Open

func (kvStore *PostgresKVStore) Open() error

Open a connection to Postgresql database, or return an error.

func (PostgresKVStore) Put

func (store PostgresKVStore) Put(schema, key string, value []byte) error

func (PostgresKVStore) Stop

func (store PostgresKVStore) Stop() error

type SqliteKVStore

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

SqliteKVStore is a struct representing a sqlite database which embeds a kvStore.

func NewSqliteKVStore

func NewSqliteKVStore(filename string, syncOnWrite bool) *SqliteKVStore

NewSqliteKVStore returns a new configured SqliteKVStore (not opened yet).

func (SqliteKVStore) Check

func (store SqliteKVStore) Check() error

func (SqliteKVStore) Delete

func (store SqliteKVStore) Delete(schema, key string) error

func (SqliteKVStore) Get

func (store SqliteKVStore) Get(schema, key string) ([]byte, bool, error)

func (SqliteKVStore) Iterate

func (store SqliteKVStore) Iterate(schema string, keyPrefix string) chan [2]string

func (SqliteKVStore) IterateKeys

func (store SqliteKVStore) IterateKeys(schema string, keyPrefix string) chan string

func (*SqliteKVStore) Open

func (kvStore *SqliteKVStore) Open() error

Open opens the database file. If the directory does not exist, it will be created.

func (SqliteKVStore) Put

func (store SqliteKVStore) Put(schema, key string, value []byte) error

func (SqliteKVStore) Stop

func (store SqliteKVStore) Stop() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL