sqlitestore

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

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

Go to latest
Published: Mar 8, 2025 License: MIT Imports: 16 Imported by: 1

README

sqlitestore

GoDoc CI

Package sqlitestore implements the blob.Store interface using SQLite.

Documentation

Overview

Package sqlitestore implements the blob.KV interface using SQLite3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Opener

func Opener(_ context.Context, addr string) (blob.StoreCloser, error)

Opener constructs a sqlitestore from a SQLite URI, for use with the store package. To specify the table name, prefix addr with "tablename@".

If poolsize=n is set, it is used to set the pool size. If compress=v is set, it is used to enable/disable compression (default true). Other query parameters are passed to SQLite.

Types

type KV

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

A KV implements the blob.KV interface using a SQLite3 database.

func (KV) Delete

func (s KV) Delete(ctx context.Context, key string) error

Delete implements part of blob.KV.

func (KV) Get

func (s KV) Get(ctx context.Context, key string) ([]byte, error)

Get implements part of blob.KV.

func (KV) Has

func (s KV) Has(ctx context.Context, keys ...string) (blob.KeySet, error)

Has implements part of blob.KV.

func (KV) Len

func (s KV) Len(ctx context.Context) (int64, error)

Len implements part of blob.KV.

func (KV) List

func (s KV) List(ctx context.Context, start string) iter.Seq2[string, error]

List implements part of blob.KV.

func (KV) Put

func (s KV) Put(ctx context.Context, opts blob.PutOptions) error

Put implements part of blob.KV.

type Options

type Options struct {
	// The name of the SQL driver to use, default "sqlite".
	Driver string

	// The number of connections to allow in the pool. If <= 0, use runtime.NumCPU.
	PoolSize int

	// If true, store blobs without compression; by default blob data are
	// compressed with Snappy.
	Uncompressed bool
}

Options are options for constructing a KV. A nil *Options is ready for use and provides default values as described.

type Store

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

func New

func New(uri string, opts *Options) (Store, error)

New creates or opens a store at the specified database.

func (Store) CAS

func (d Store) CAS(ctx context.Context, name string) (blob.CAS, error)

func (Store) Close

func (s Store) Close(ctx context.Context) error

Close implements part of the blob.StoreCloser interface.

func (Store) KV

func (d Store) KV(ctx context.Context, name string) (blob.KV, error)

func (Store) Sub

func (d Store) Sub(ctx context.Context, name string) (blob.Store, error)

Jump to

Keyboard shortcuts

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