sqlite

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

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

Go to latest
Published: Nov 10, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package sqlite contains an implementation of the `gokv.Store` interface for sqlite.

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Path:      "sqlite.db",
	TableName: defaultDBname,
	Codec:     encoding.JSON,
}

DefaultOptions is an Options object with default values.

Functions

This section is empty.

Types

type Client

type Client struct {
	*sql.Client
}

Client is a gokv.Store implementation for sqlite.

func NewClient

func NewClient(options Options) (Client, error)

NewClient creates a new sqlite client.

You must call the Close() method on the client when you're done working with it.

func (Client) Close

func (c Client) Close() error

Close closes the client. It must be called to make sure that all open transactions finish and to release all DB resources.

func (Client) Delete

func (c Client) Delete(k string) error

Delete deletes the stored value for the given key.

func (Client) Get

func (c Client) Get(k string, v any) (found bool, err error)

Get retrieves the stored value for the given key.

func (Client) Set

func (c Client) Set(k string, v any) error

type Options

type Options struct {
	// Path
	Path string
	// Name of the table in which the key-value pairs are stored.
	// Optional ("Item" by default).
	TableName string
	// Encoding format.
	// Optional (encoding.JSON by default).
	Codec encoding.Codec
	Db    *gosql.DB
}

Options are the options for the sqlite client.

Jump to

Keyboard shortcuts

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