kvs

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadAsBool added in v0.7.5

func LoadAsBool(kvs KVS, k string) (bool, error)

func LoadAsFloat added in v0.7.5

func LoadAsFloat(kvs KVS, k string) (float64, error)

func LoadAsFloatOr added in v0.7.5

func LoadAsFloatOr(kvs KVS, k string, d float64) (float64, error)

func LoadAsInt added in v0.7.5

func LoadAsInt(kvs KVS, k string) (int, error)

func LoadAsIntOr added in v0.7.5

func LoadAsIntOr(kvs KVS, k string, d int) (int, error)

func LoadAsString added in v0.7.5

func LoadAsString(kvs KVS, k string) (string, error)

func LoadAsStringOr added in v0.7.5

func LoadAsStringOr(kvs KVS, k string, d string) (string, error)

func LoadAsUint added in v0.7.5

func LoadAsUint(kvs KVS, k string) (uint, error)

func LoadAsUintOr added in v0.7.5

func LoadAsUintOr(kvs KVS, k string, d uint) (uint, error)

func LoadTo added in v0.7.5

func LoadTo(kvs KVS, k string, to any) error

Types

type Cfg

type Cfg struct {
	Type Type        `yaml:"type" json:"type"`
	Cfg  interface{} `yaml:"cfg"  json:"cfg"`
}

type DBModel added in v0.7.5

type DBModel struct {
	RowID     int64     `db:"rowid"`
	K         string    `db:"k"`
	V         string    `db:"v"`
	UpdatedAt time.Time `db:"updated_at"`
}

type InMemKVS

type InMemKVS struct {
	*InMemKVSCfg
	// contains filtered or unexported fields
}

func (*InMemKVS) Close added in v0.7.5

func (i *InMemKVS) Close() error

func (*InMemKVS) Collect

func (i *InMemKVS) Collect() (map[string]any, error)

func (*InMemKVS) CollectAsString

func (i *InMemKVS) CollectAsString() (map[string]string, error)

func (*InMemKVS) Del

func (i *InMemKVS) Del(k string) error

func (*InMemKVS) GetCfg added in v0.7.5

func (i *InMemKVS) GetCfg() interface{}

func (*InMemKVS) Load

func (i *InMemKVS) Load(k string) (any, bool, error)

func (*InMemKVS) LoadAndDelete

func (i *InMemKVS) LoadAndDelete(k string) (any, bool, error)

func (*InMemKVS) LoadAsBool

func (i *InMemKVS) LoadAsBool(k string) (bool, error)

func (*InMemKVS) LoadAsFloat

func (i *InMemKVS) LoadAsFloat(k string) (float64, error)

func (*InMemKVS) LoadAsFloatOr

func (i *InMemKVS) LoadAsFloatOr(k string, d float64) (float64, error)

func (*InMemKVS) LoadAsInt

func (i *InMemKVS) LoadAsInt(k string) (int, error)

func (*InMemKVS) LoadAsIntOr

func (i *InMemKVS) LoadAsIntOr(k string, d int) (int, error)

func (*InMemKVS) LoadAsString

func (i *InMemKVS) LoadAsString(k string) (string, error)

func (*InMemKVS) LoadAsStringOr

func (i *InMemKVS) LoadAsStringOr(k string, d string) (string, error)

func (*InMemKVS) LoadAsUint

func (i *InMemKVS) LoadAsUint(k string) (uint, error)

func (*InMemKVS) LoadAsUintOr

func (i *InMemKVS) LoadAsUintOr(k string, d uint) (uint, error)

func (*InMemKVS) LoadOrStore

func (i *InMemKVS) LoadOrStore(k string, v any) (any, bool, error)

func (*InMemKVS) LoadTo

func (i *InMemKVS) LoadTo(k string, to any) error

func (*InMemKVS) Open added in v0.7.5

func (i *InMemKVS) Open() error

func (*InMemKVS) Range

func (i *InMemKVS) Range(f func(k string, v any) bool) error

func (*InMemKVS) Store

func (i *InMemKVS) Store(k string, v any) error

func (*InMemKVS) StoreAsString

func (i *InMemKVS) StoreAsString(k string, v any) error

func (*InMemKVS) Type added in v0.7.5

func (i *InMemKVS) Type() interface{}

type InMemKVSCfg

type InMemKVSCfg struct{}

func NewInMemKVSCfg

func NewInMemKVSCfg() *InMemKVSCfg

type KVS

type KVS interface {
	plugin.Plugin

	Open() error
	Close() error

	Store(k string, v any) error
	StoreAsString(k string, v any) error
	Load(k string) (any, bool, error)
	LoadOrStore(k string, v any) (any, bool, error)
	LoadAndDelete(k string) (any, bool, error)
	Del(k string) error
	LoadAsBool(k string) (bool, error)
	LoadAsString(k string) (string, error)
	LoadAsStringOr(k string, d string) (string, error)
	LoadAsInt(k string) (int, error)
	LoadAsIntOr(k string, d int) (int, error)
	LoadAsUint(k string) (uint, error)
	LoadAsUintOr(k string, d uint) (uint, error)
	LoadAsFloat(k string) (float64, error)
	LoadAsFloatOr(k string, d float64) (float64, error)
	LoadTo(k string, to any) error
	Collect() (map[string]any, error)
	CollectAsString() (map[string]string, error)
	Range(func(k string, v any) bool) error
}

func NewInMemKVS

func NewInMemKVS() KVS

func NewSQLite3KVS added in v0.7.5

func NewSQLite3KVS() KVS

type SQLite3KVS added in v0.7.5

type SQLite3KVS struct {
	*SQLite3KVSCfg
	// contains filtered or unexported fields
}

func (*SQLite3KVS) Close added in v0.7.5

func (s *SQLite3KVS) Close() error

func (*SQLite3KVS) Collect added in v0.7.5

func (s *SQLite3KVS) Collect() (map[string]any, error)

func (*SQLite3KVS) CollectAsString added in v0.7.5

func (s *SQLite3KVS) CollectAsString() (map[string]string, error)

func (*SQLite3KVS) Del added in v0.7.5

func (s *SQLite3KVS) Del(k string) error

func (*SQLite3KVS) GetCfg added in v0.7.5

func (s *SQLite3KVS) GetCfg() interface{}

func (*SQLite3KVS) Load added in v0.7.5

func (s *SQLite3KVS) Load(k string) (any, bool, error)

func (*SQLite3KVS) LoadAndDelete added in v0.7.5

func (s *SQLite3KVS) LoadAndDelete(k string) (any, bool, error)

func (*SQLite3KVS) LoadAsBool added in v0.7.5

func (s *SQLite3KVS) LoadAsBool(k string) (bool, error)

func (*SQLite3KVS) LoadAsFloat added in v0.7.5

func (s *SQLite3KVS) LoadAsFloat(k string) (float64, error)

func (*SQLite3KVS) LoadAsFloatOr added in v0.7.5

func (s *SQLite3KVS) LoadAsFloatOr(k string, d float64) (float64, error)

func (*SQLite3KVS) LoadAsInt added in v0.7.5

func (s *SQLite3KVS) LoadAsInt(k string) (int, error)

func (*SQLite3KVS) LoadAsIntOr added in v0.7.5

func (s *SQLite3KVS) LoadAsIntOr(k string, d int) (int, error)

func (*SQLite3KVS) LoadAsString added in v0.7.5

func (s *SQLite3KVS) LoadAsString(k string) (string, error)

func (*SQLite3KVS) LoadAsStringOr added in v0.7.5

func (s *SQLite3KVS) LoadAsStringOr(k string, d string) (string, error)

func (*SQLite3KVS) LoadAsUint added in v0.7.5

func (s *SQLite3KVS) LoadAsUint(k string) (uint, error)

func (*SQLite3KVS) LoadAsUintOr added in v0.7.5

func (s *SQLite3KVS) LoadAsUintOr(k string, d uint) (uint, error)

func (*SQLite3KVS) LoadOrStore added in v0.7.5

func (s *SQLite3KVS) LoadOrStore(k string, v any) (any, bool, error)

func (*SQLite3KVS) LoadTo added in v0.7.5

func (s *SQLite3KVS) LoadTo(k string, to any) error

func (*SQLite3KVS) Open added in v0.7.5

func (s *SQLite3KVS) Open() error

func (*SQLite3KVS) Range added in v0.7.5

func (s *SQLite3KVS) Range(f func(k string, v any) bool) error

func (*SQLite3KVS) Store added in v0.7.5

func (s *SQLite3KVS) Store(k string, v any) error

func (*SQLite3KVS) StoreAsString added in v0.7.5

func (s *SQLite3KVS) StoreAsString(k string, v any) error

func (*SQLite3KVS) Type added in v0.7.5

func (s *SQLite3KVS) Type() interface{}

type SQLite3KVSCfg added in v0.7.5

type SQLite3KVSCfg struct {
	Path  string `json:"path"  yaml:"path" validate:"required"`
	Table string `json:"table" yaml:"table"`
	DDL   string `json:"ddl"   yaml:"ddl"`
}

func NewSQLite3KVSCfg added in v0.7.5

func NewSQLite3KVSCfg() *SQLite3KVSCfg

type Type

type Type string
const TypeInMem Type = "inmem"
const (
	TypeSQLite3 Type = "sqlite3"
)

Jump to

Keyboard shortcuts

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