kv

package
v5.0.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caster

type Caster interface {
	Bool() bool
	Bytes() []byte
	Interface() interface{}
	Int() int
	Int64() int64
	Duration() time.Duration
	String() string
	StringMap() map[string]string
	StringArray() []string
	Slice() []interface{}
	Map() map[string]interface{}
	Scanner
}

type Decrypter

type Decrypter interface {
	Decrypt(string) ([]byte, error)
}

type Encrypter

type Encrypter interface {
	Encrypt([]byte) (string, error)
}

type Getter

type Getter func() any

type Marshaller

type Marshaller interface {
	Marshal(interface{}) ([]byte, error)
}

type Option

type Option func(*Options)

func WithBinary

func WithBinary() Option

func WithDecrypt

func WithDecrypt(d Decrypter) Option

func WithEncrypt

func WithEncrypt(e Encrypter) Option

func WithInitData

func WithInitData(data interface{}) Option

func WithJSON

func WithJSON() Option

func WithMarshaller

func WithMarshaller(m Marshaller) Option

func WithReadOnly

func WithReadOnly() Option

func WithReferencePool

func WithReferencePool(key string, ref *openurl.Pool[Values]) Option

func WithSetCallback

func WithSetCallback(f func([]string, interface{}) error) Option

func WithStorer

func WithStorer(data Storer) Option

func WithString

func WithString() Option

func WithUnmarshaler

func WithUnmarshaler(u Unmarshaler) Option

func WithYAML

func WithYAML() Option

type Options

type Options struct {
	InitData interface{}

	Storer

	Unmarshaler
	Marshaller
	Encrypter
	Decrypter

	// Additional callback after Set is called
	SetCallback func([]string, interface{}) error

	// Do not create any resources
	ReadOnly bool

	ReferencePool map[string]*openurl.Pool[Values]

	// Used to pass other potential options
	Context context.Context
}

type Scanner

type Scanner interface {
	Scan(out any, options ...Option) error
}

type Store

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

func NewStore

func NewStore(opt ...Option) *Store

func (*Store) As

func (m *Store) As(out any) bool

func (*Store) Clone

func (c *Store) Clone() *Store

Clone preserves your previous “shared store” behavior: clones share the same underlying state. (Matches your old pointer-field pattern.)

func (*Store) Close

func (m *Store) Close(_ context.Context) error

func (*Store) Context

func (m *Store) Context(ctx context.Context) Values

func (*Store) Default

func (m *Store) Default(d any) Values

func (*Store) Del

func (m *Store) Del() error

func (*Store) Done

func (m *Store) Done() <-chan struct{}

func (*Store) Empty

func (c *Store) Empty()

func (*Store) Flush

func (m *Store) Flush()

func (*Store) Get

func (m *Store) Get() any

func (*Store) Key

func (m *Store) Key() []string

func (*Store) Options

func (m *Store) Options() *Options

func (*Store) RLock

func (m *Store) RLock()

func (*Store) RUnlock

func (m *Store) RUnlock()

func (*Store) Reset

func (m *Store) Reset()

func (*Store) Save

func (m *Store) Save(string, string) error

func (*Store) Set

func (m *Store) Set(value any) error

func (*Store) Val

func (m *Store) Val(path ...string) Values

func (*Store) Watch

func (m *Store) Watch(opts ...watch.WatchOption) (watch.Receiver, error)

type Storer

type Storer interface {
	Context(ctx context.Context) Values
	Options() *Options
	Key() []string
	Val(path ...string) Values
	Default(def any) Values
	Get() any
	Set(value any) error
	Del() error
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte, interface{}) error
}

type Values

type Values interface {
	Storer
	Caster
}

type WalkOption

type WalkOption func(*WalkOptions)

func WithInterceptor

func WithInterceptor(f func(i int, v any) (bool, any)) WalkOption

type WalkOptions

type WalkOptions struct {
	Interceptor func(i int, v any) (bool, any)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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