Documentation ¶
Index ¶
- type KVStore
- type MemoryKVStore
- func (kvStore *MemoryKVStore) Delete(schema, key string) error
- func (kvStore *MemoryKVStore) Get(schema, key string) ([]byte, bool, error)
- func (kvStore *MemoryKVStore) Iterate(schema string, keyPrefix string) chan [2]string
- func (kvStore *MemoryKVStore) IterateKeys(schema string, keyPrefix string) chan string
- func (kvStore *MemoryKVStore) Put(schema, key string, value []byte) error
- type PostgresConfig
- type PostgresKVStore
- func (store PostgresKVStore) Check() error
- func (store PostgresKVStore) Delete(schema, key string) error
- func (store PostgresKVStore) Get(schema, key string) ([]byte, bool, error)
- func (store PostgresKVStore) Iterate(schema string, keyPrefix string) chan [2]string
- func (store PostgresKVStore) IterateKeys(schema string, keyPrefix string) chan string
- func (kvStore *PostgresKVStore) Open() error
- func (store PostgresKVStore) Put(schema, key string, value []byte) error
- func (store PostgresKVStore) Stop() error
- type SqliteKVStore
- func (store SqliteKVStore) Check() error
- func (store SqliteKVStore) Delete(schema, key string) error
- func (store SqliteKVStore) Get(schema, key string) ([]byte, bool, error)
- func (store SqliteKVStore) Iterate(schema string, keyPrefix string) chan [2]string
- func (store SqliteKVStore) IterateKeys(schema string, keyPrefix string) chan string
- func (kvStore *SqliteKVStore) Open() error
- func (store SqliteKVStore) Put(schema, key string, value []byte) error
- func (store SqliteKVStore) Stop() error
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
type PostgresConfig ¶
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) IterateKeys ¶
func (*PostgresKVStore) Open ¶
func (kvStore *PostgresKVStore) Open() error
Open a connection to Postgresql database, or return an 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) IterateKeys ¶
func (*SqliteKVStore) Open ¶
func (kvStore *SqliteKVStore) Open() error
Open opens the database file. If the directory does not exist, it will be created.