kv

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KVEntry added in v2.8.1

type KVEntry struct {
	Key       string     `gorm:"column:key;primaryKey"`
	Value     string     `gorm:"column:value"`
	CreatedAt time.Time  `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt *time.Time `gorm:"column:updated_at;autoUpdateTime"`
}

KVEntry stores lightweight application state as arbitrary key/value pairs.

func (KVEntry) TableName added in v2.8.1

func (KVEntry) TableName() string

type KVService

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

KVService persists lightweight application state in the kv table.

func NewKVService

func NewKVService(db *database.DB) *KVService

func (*KVService) Delete

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

func (*KVService) Get

func (s *KVService) Get(ctx context.Context, key string) (string, bool, error)

func (*KVService) GetBool

func (s *KVService) GetBool(ctx context.Context, key string, defaultValue bool) (bool, error)

func (*KVService) GetInt64

func (s *KVService) GetInt64(ctx context.Context, key string, defaultValue int64) (int64, error)

func (*KVService) GetTyped added in v2.10.0

func (s *KVService) GetTyped[T any](ctx context.Context, key string, defaultValue T, parse func(string) (T, error)) (T, error)

GetTyped loads one kv entry and parses it, returning defaultValue when the key is absent or unreadable.

func (*KVService) IncrementInt64

func (s *KVService) IncrementInt64(ctx context.Context, key string, delta int64) (int64, error)

func (*KVService) ListByPrefix

func (s *KVService) ListByPrefix(ctx context.Context, prefix string) ([]KVEntry, error)

func (*KVService) Set

func (s *KVService) Set(ctx context.Context, key, value string) error

func (*KVService) SetBool

func (s *KVService) SetBool(ctx context.Context, key string, value bool) error

Jump to

Keyboard shortcuts

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