sqkv

package module
v0.0.0-...-fd091c5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 7 Imported by: 0

README

SQKV

SQLite3 K/V database

License

MIT

Documentation

Index

Constants

View Source
const (
	OpenJournalModeDelete   = "delete"
	OpenJournalModeTruncate = "truncate"
	OpenJournalModePersist  = "persist"
	OpenJournalModeMemory   = "memory"
	OpenJournalModeWAL      = "wal"
	OpenJournalModeOff      = "off"
)
View Source
const DefaultBucket = "SQKV"

Variables

View Source
var (
	ErrBucketNameEmpty    = errors.New("bucket name cannot be empty")
	ErrBucketDoesNotExist = errors.New("bucket does not exist")
	ErrBucketExists       = errors.New("bucket already exists")
	ErrKeyDoesNotExist    = errors.New("key does not exist in bucket")
)

Functions

This section is empty.

Types

type Bucket

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

Bucket is a KV bucket

func (*Bucket) Delete

func (b *Bucket) Delete(key string) error

Delete removes a value from the bucket

func (*Bucket) Get

func (b *Bucket) Get(key string) (string, error)

Get returns a value from the bucket

func (*Bucket) Put

func (b *Bucket) Put(key, value string) error

Put sets a value in the bucket

type DB

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

DB is an SQKV database

func Open

func Open(path string, opts ...OpenOption) (*DB, error)

Open opens (or creates) a new SQKV database

func (*DB) Bucket

func (d *DB) Bucket(name string) (*Bucket, error)

Bucket gets a bucket by name, or returns nil if it doesn't exist

func (*DB) Close

func (d *DB) Close() error

Close closes the connection to the database

func (*DB) Conn

func (d *DB) Conn() (*sql.Conn, error)

Conn returns a direct DB connection

func (*DB) CreateBucket

func (d *DB) CreateBucket(name string) (*Bucket, error)

CreateBucket creates a new bucket and returns it. Returns an error if the bucket already exists or name is empty.

func (*DB) CreateBucketIfNotExist

func (d *DB) CreateBucketIfNotExist(name string) (*Bucket, error)

CreateBucketIfNotExist creates a new bucket (if it does not exist) and returns it. Returns an error if name is empty.

func (*DB) Delete

func (d *DB) Delete(key string) error

Delete removes a value from the default bucket

func (*DB) Get

func (d *DB) Get(key string) (string, error)

Get returns a value from the default bucket

func (*DB) Put

func (d *DB) Put(key, value string) error

Put sets a value in the default bucket

type OpenCache

type OpenCache string

OpenCache for setting the cache mode

const (
	OpenCacheShared  OpenCache = "shared"
	OpenCachePrivate OpenCache = "private"
)

type OpenConfig

type OpenConfig struct {
	Mode        OpenMode
	Cache       OpenCache
	JournalMode OpenJournalMode
}

OpenConfig is a configuration for opening a DB

func (OpenConfig) String

func (oc OpenConfig) String() string

String implements fmt.Stringer

type OpenJournalMode

type OpenJournalMode string

OpenJournalMode for setting the journal mode

type OpenMode

type OpenMode string

OpenMode for opening a DB

const (
	OpenModeReadOnly        OpenMode = "ro"
	OpenModeReadWrite       OpenMode = "rw"
	OpenModeReadWriteCreate OpenMode = "rwc"
	OpenModeMemory          OpenMode = "memory"
)

type OpenOption

type OpenOption func(*OpenConfig)

OpenOption is a func for setting open config values

func WithCache

func WithCache(cache OpenCache) OpenOption

WithCache sets the cache for opening the DB

func WithJournalMode

func WithJournalMode(journalMode OpenJournalMode) OpenOption

WithJournalMode sets the journal mode for the DB

func WithMode

func WithMode(mode OpenMode) OpenOption

WithMode sets the mode for opening the DB

Jump to

Keyboard shortcuts

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