kvlite

package module
v0.0.0-...-7d03531 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: MIT Imports: 17 Imported by: 1

README

kvlite

import "github.com/cmcoffee/go-kvlite"

Package 'kvlite' provides a Key Value interface upon SQLite.

Constants

const (
    RESERVED = "KVLite"
    NONE     = ""
)

Variables

var ErrBadPadlock = errors.New("kvlite: Invalid padlock provided, unable to open database.")

ErrBadPadlock is returned if kvlite.Open is used with incorrect padlock set on database.

var ErrBadPass = errors.New("kvlite: Invalid passphrase provided, unable to remove lock!")

ErrBadPass is returned if an Unlock is attempted with the incorrect passphrase.

var ErrNotUnlocked = errors.New("kvlite: Cannot apply new lock on top of existing lock, must remove old lock first.")

ErrLocked is returned if a new Lock is attempted on a database that is currently locked.

func Lock

func Lock(filepath, passphrase string, padlock []byte) (err error)

Sets a lock on Store database, requires a passphrase (for unlocking in future) and padlock when opening database in future.

func Unlock

func Unlock(filepath, passphrase string) (err error)

Removes lock on Store database, strips the requirement for padlock for opening database, requires passphrase set on initial lock.

type Store

type Store struct {
    // contains filtered or unexported fields
}
func FastOpen
func FastOpen(filePath string, key string) (*Store, error)

Open Database without auto-generated encryption key, instead specify key, if no key specific will be random.

func MemStore
func MemStore() (*Store, error)

Open Memory-Only Database with random key.

func Open
func Open(filePath string, padlock ...[]byte) (*Store, error)

Open or Creates a new *Store will use auto-created encryption key.

func (*Store) Close
func (s *Store) Close() error

Close Store.

func (*Store) CountKeys
func (s *Store) CountKeys(table string, filters ...string) (count uint32, err error)

List all keys in table, only those matching filter if specified.

func (*Store) CryptKey
func (s *Store) CryptKey(key []byte)

Manually override encryption key used with CryptSet.

func (*Store) CryptReset
func (s *Store) CryptReset() error

Truncates the KVLite table to reset the encryption keys for database.

func (*Store) CryptSet
func (s *Store) CryptSet(table string, key interface{}, val interface{}) (err error)

Writes encrypted value to Store datastore.

func (*Store) Get
func (s *Store) Get(table string, key interface{}, output interface{}) (found bool, err error)

Retreive a value at key in table specified.

func (*Store) ListIKeys
func (s *Store) ListIKeys(table string, filters ...string) (keyList []int, err error)

List all integer keys in table, matching filter if specified.

func (*Store) ListKeys
func (s *Store) ListKeys(table string, filters ...string) (keyList []string, err error)

List all keys in table, only those matching filter if specified.

func (*Store) ListTables
func (s *Store) ListTables(filters ...string) (cList []string, err error)

List all tables, if filter specified only tables that match filter.

func (*Store) Set
func (s *Store) Set(table string, key interface{}, val interface{}) (err error)

Stores value in Store datastore.

func (*Store) Truncate
func (s *Store) Truncate(table string) (err error)

Truncates a table in Store datastore.

func (*Store) Unset
func (s *Store) Unset(table string, key interface{}) error

Unset/remove key in table specified.


Generated by godoc2md

Documentation

Overview

Package 'kvlite' provides a Key Value interface upon SQLite.

Index

Constants

View Source
const (
	RESERVED = "KVLite"
	NONE     = ""
)

Variables

View Source
var ErrBadPadlock = errors.New("kvlite: Invalid padlock provided, unable to open database.")

ErrBadPadlock is returned if kvlite.Open is used with incorrect padlock set on database.

View Source
var ErrBadPass = errors.New("kvlite: Invalid passphrase provided, unable to remove lock!")

ErrBadPass is returned if an Unlock is attempted with the incorrect passphrase.

View Source
var ErrNotUnlocked = errors.New("kvlite: Cannot apply new lock on top of existing lock, must remove old lock first.")

ErrLocked is returned if a new Lock is attempted on a database that is currently locked.

Functions

func Lock

func Lock(filepath, passphrase string, padlock []byte) (err error)

Sets a lock on Store database, requires a passphrase (for unlocking in future) and padlock when opening database in future.

func Unlock

func Unlock(filepath, passphrase string) (err error)

Removes lock on Store database, strips the requirement for padlock for opening database, requires passphrase set on initial lock.

Types

type Store

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

func FastOpen

func FastOpen(filePath string, key string) (*Store, error)

Open Database without auto-generated encryption key, instead specify key, if no key specific will be random.

func MemStore

func MemStore() (*Store, error)

Open Memory-Only Database with random key.

func Open

func Open(filePath string, padlock ...[]byte) (*Store, error)

Open or Creates a new *Store will use auto-created encryption key.

func (*Store) Close

func (s *Store) Close() error

Close Store.

func (*Store) CountKeys

func (s *Store) CountKeys(table string, filters ...string) (count uint32, err error)

List all keys in table, only those matching filter if specified.

func (*Store) CryptKey

func (s *Store) CryptKey(key []byte)

Manually override encryption key used with CryptSet.

func (*Store) CryptReset

func (s *Store) CryptReset() error

Truncates the KVLite table to reset the encryption keys for database.

func (*Store) CryptSet

func (s *Store) CryptSet(table string, key interface{}, val interface{}) (err error)

Writes encrypted value to Store datastore.

func (*Store) Get

func (s *Store) Get(table string, key interface{}, output interface{}) (found bool, err error)

Retreive a value at key in table specified.

func (*Store) ListKeys

func (s *Store) ListKeys(table string, filters ...string) (keyList []string, err error)

List all keys in table, only those matching filter if specified.

func (*Store) ListNKeys

func (s *Store) ListNKeys(table string, filters ...string) (keyList []int, err error)

List all numeric keys in table, matching filter if specified.

func (*Store) ListTables

func (s *Store) ListTables(filters ...string) (cList []string, err error)

List all tables, if filter specified only tables that match filter.

func (*Store) SGet

func (s *Store) SGet(table string, key interface{}) (output string)

Retrieves a value as string at key in table specified.

func (*Store) Set

func (s *Store) Set(table string, key interface{}, val interface{}) (err error)

Stores value in Store datastore.

func (*Store) Shrink

func (s *Store) Shrink() (err error)

Uses VACUUM command to shrink sqlite database.

func (*Store) Truncate

func (s *Store) Truncate(table string) (err error)

Truncates a table in Store datastore.

func (*Store) Unset

func (s *Store) Unset(table string, key interface{}) error

Unset/remove key in table specified.

Jump to

Keyboard shortcuts

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