repo

package
v0.0.0-...-96ae7f5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDBPath is the default path to the SQLite database.
	DefaultDBPath = "kv.db"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyExistsError

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

func NewKeyExistsError

func NewKeyExistsError(key string) KeyExistsError

func (KeyExistsError) Error

func (e KeyExistsError) Error() string

type KeyNotFoundError

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

func NewKeyNotFoundError

func NewKeyNotFoundError(key string) KeyNotFoundError

func (KeyNotFoundError) Error

func (e KeyNotFoundError) Error() string

type Repo

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

Repo represents the key-value store repository.

func New

func New(dbPath string, logger *slog.Logger) (*Repo, error)

New initializes a new Repo.

func (*Repo) Close

func (r *Repo) Close() error

Close closes the repository and the underlying database connection.

func (*Repo) Create

func (r *Repo) Create(key, value string) error

Create creates a new key-value pair.

func (*Repo) Delete

func (r *Repo) Delete(key string) error

Delete deletes the key-value pair associated with the given key. It returns an error if the key doesn't exist.

func (*Repo) Get

func (r *Repo) Get(key string) (string, error)

Get retrieves the value associated with the given key.

func (*Repo) Update

func (r *Repo) Update(key, value string) error

Update updates the value associated with the given key.

Jump to

Keyboard shortcuts

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