sqlitestore

package module
v0.0.0-...-05b526c Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 17 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.

  • If poolsize=n is set, it is used to set the pool size to n connections.
  • If compress=v is set, it is used to enable/disable compression (default true).
  • If journal=m is set, it is used to set the journaling mode.

Any other query parameters are passed to SQLite verbatim.

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

	// If set, set the journal mode of the database to this value.
	// See: https://sqlite.org/pragma.html#pragma_journal_mode
	JournalMode string
}

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 {
	*monitor.M[*sqlDB, KV]
}

func New

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

New creates or opens a store at the specified database.

func (Store) Close

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

Close implements part of the blob.StoreCloser interface.

Jump to

Keyboard shortcuts

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