store

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinPath

func JoinPath(path []Path) string

JoinPath joins all path elements into a single path.

func OrderedMapKeys

func OrderedMapKeys[M ~map[K]V, K cmp.Ordered, V any](m M) []K

OrderedMapKeys returns the keys of the map m in sorted order.

Types

type Path

type Path struct {
	Type PathType
	Elem string
}

func SplitPath

func SplitPath(key string) ([]Path, error)

SplitPath splits key into individual path elements.

type PathType

type PathType int
const (
	PathTypeKey   PathType = iota // PathTypeKey is map key like a/b in a[0][1].b
	PathTypeIndex                 // PathTypeIndex is array index like 0/1 in a[0][1].b
)

type Storage

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

Storage is a key-value store that verifies the format of the key.

func NewStorage

func NewStorage() *Storage

func (*Storage) Copy

func (s *Storage) Copy() *Storage

Copy returns a new copy of the storage.

func (*Storage) Data

func (s *Storage) Data() map[string]string

Data returns the data of the storage.

func (*Storage) Get

func (s *Storage) Get(key string) (string, bool)

Get returns the value of the key, and false if the key does not exist.

func (*Storage) Has

func (s *Storage) Has(key string) bool

Has returns whether the key exists.

func (*Storage) Keys

func (s *Storage) Keys() []string

Keys returns the sorted keys of the storage.

func (*Storage) Set

func (s *Storage) Set(key, val string) error

Set stores the value of the key.

func (*Storage) SubKeys

func (s *Storage) SubKeys(key string) ([]string, error)

SubKeys returns the sorted sub keys of the key.

Jump to

Keyboard shortcuts

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