sqltplainkv

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

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package SQLtplainkv is a package implementing PlainKVer using SQlite

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBucketIdTooLong error = errors.New(`bucket id too long`)
	ErrKeyTooLong      error = errors.New(`key too long`)
	ErrValueTooLong    error = errors.New(`value too large`)
)

Functions

This section is empty.

Types

type SQLtPlainKV

type SQLtPlainKV struct {
	DSN string // Data Source Name
	// contains filtered or unexported fields
}

SQLtPlainKV is a key-value database that uses SQLite database as its storage backend

func NewSQLtPlainKV

func NewSQLtPlainKV(dsn string, autoClose bool) *SQLtPlainKV

NewSQLtPlainKV creates a new SQLtPlainKV object This is the recommended method

func (*SQLtPlainKV) Begin

func (p *SQLtPlainKV) Begin() error

Begin a transaction

func (*SQLtPlainKV) Close

func (p *SQLtPlainKV) Close() error

Close closes the database

func (*SQLtPlainKV) Commit

func (p *SQLtPlainKV) Commit() error

Commit transaction

func (*SQLtPlainKV) Del

func (p *SQLtPlainKV) Del(key string) error

Del deletes a record with the provided key

func (*SQLtPlainKV) Get

func (p *SQLtPlainKV) Get(key string) ([]byte, error)

Get retrieves a record using a key

func (*SQLtPlainKV) GetMime

func (p *SQLtPlainKV) GetMime(key string) (string, error)

Get retrieves a record using a key

func (*SQLtPlainKV) ListKeys

func (p *SQLtPlainKV) ListKeys(pattern string) ([]string, error)

ListKeys lists all keys containing the current pattern

func (*SQLtPlainKV) Open

func (p *SQLtPlainKV) Open() error

Open a connection to a MySQL database database

func (*SQLtPlainKV) Rollback

func (p *SQLtPlainKV) Rollback() error

Rollback transaction

func (*SQLtPlainKV) Set

func (p *SQLtPlainKV) Set(key string, value []byte) error

Set creates or updates the record by the value

func (*SQLtPlainKV) SetBucket

func (p *SQLtPlainKV) SetBucket(bucket string)

SetBucket sets the current bucket. If set, all succeeding values will be retrieved and stored by the bucket name

func (*SQLtPlainKV) SetMime

func (p *SQLtPlainKV) SetMime(key string, mime string) error

SetMime sets the mime of the value stored

func (*SQLtPlainKV) SetTableName

func (p *SQLtPlainKV) SetTableName(tableName string)

SetTableName changes the default table name

func (*SQLtPlainKV) Tally

func (p *SQLtPlainKV) Tally(key string, offset int) (int, error)

Tally gets the current tally of a key. To start with a pre-defined number, set the offset variable It automatically creates new key if it does not exist

func (*SQLtPlainKV) TallyDecr

func (p *SQLtPlainKV) TallyDecr(key string) (int, error)

Decr decrements the tally

func (*SQLtPlainKV) TallyIncr

func (p *SQLtPlainKV) TallyIncr(key string) (int, error)

Incr increments the tally

func (*SQLtPlainKV) TallyReset

func (p *SQLtPlainKV) TallyReset(key string) error

Reset resets tally to zero

Jump to

Keyboard shortcuts

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