kvs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package kvs implements a key/value store. These functions provide for object serialization/deserialization to the kvs.

Package kvs implements a key/value store. This implementation is for SQLITE3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KVS

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

KVS is an instance for key/value storage.

func New

func New(dbConnectionString string, table string) (KVS, error)

New creates a new key/value store, with a new or existing table, in the database for key/value storage. The returned object has a single connection. If performance is an issue, create a pool of connections. The GO sql package insures single threaded access to the connection, and thus it is thread safe.

func (KVS) Close

func (kvs KVS) Close() error

Close closes the database connection.

func (KVS) Delete

func (kvs KVS) Delete(key string) (int64, error)

Delete deletes a key from the KVS; returns the count, which is zero (and no error) if the key did not exist.

func (KVS) DeleteStore

func (kvs KVS) DeleteStore() error

DeleteStore drops the table associated with the KVS.

func (KVS) Deserialize

func (kvs KVS) Deserialize(key string, obj interface{}) error

Deserialize deserializes an object from the KVS. Note that the caller needs to call with a pointer to the object to deserialize. If fields in the persisted object are non-nil, they will overwrite fields in the provided object, otherwise values in the provide object will be in the returned object. If the key is not in the KVS, obj is unchanged and there is no error.

func (KVS) Get

func (kvs KVS) Get(key string) ([]byte, error)

Get gets a value from the KVS. If the return data and error are both nil, the key did not exist.

func (KVS) Keys added in v0.2.0

func (kvs KVS) Keys() ([]string, error)

Keys returns all keys in the store.

func (KVS) Serialize

func (kvs KVS) Serialize(key string, obj interface{}) error

Serialize serializes an object into the KVS.

func (KVS) Set

func (kvs KVS) Set(key string, value []byte) error

Set sets a value for the specified key in the KVS.

Jump to

Keyboard shortcuts

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