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 ¶
- type KVS
- func (kvs KVS) Close() error
- func (kvs KVS) Delete(key string) (int64, error)
- func (kvs KVS) DeleteStore() error
- func (kvs KVS) Deserialize(key string, obj interface{}) error
- func (kvs KVS) Get(key string) ([]byte, error)
- func (kvs KVS) Keys() ([]string, error)
- func (kvs KVS) Serialize(key string, obj interface{}) error
- func (kvs KVS) Set(key string, value []byte) error
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 ¶
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) Delete ¶
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 ¶
DeleteStore drops the table associated with the KVS.
func (KVS) Deserialize ¶
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 ¶
Get gets a value from the KVS. If the return data and error are both nil, the key did not exist.