Documentation
¶
Overview ¶
Package memkv implements an in-memory key/value store with hierarchical path-based operations designed for template rendering.
Originally from github.com/kelseyhightower/memkv, internalized for maintenance.
Index ¶
- Variables
- type KVPair
- type KVPairs
- type KeyError
- type Store
- func (s *Store) Del(key string)
- func (s *Store) Exists(key string) bool
- func (s *Store) Get(key string) (KVPair, error)
- func (s *Store) GetAll(pattern string) (KVPairs, error)
- func (s *Store) GetAllValues(pattern string) ([]string, error)
- func (s *Store) GetValue(key string, defaultValue ...string) (string, error)
- func (s *Store) List(filePath string) []string
- func (s *Store) ListDir(filePath string) []string
- func (s *Store) Purge()
- func (s *Store) Set(key, value string)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotExist is returned when a key does not exist in the store. ErrNotExist = errors.New("key does not exist") // ErrNoMatch is returned when no keys match a pattern. ErrNoMatch = errors.New("no keys match") )
Functions ¶
This section is empty.
Types ¶
type KVPairs ¶
type KVPairs []KVPair
KVPairs is a slice of KVPair that implements sort.Interface for sorting by key.
type Store ¶
type Store struct {
FuncMap map[string]interface{}
// contains filtered or unexported fields
}
Store is an in-memory key-value store safe for concurrent access. It provides hierarchical path-based operations suitable for template rendering.
func New ¶
func New() *Store
New creates and initializes a new Store with template functions pre-registered.
func (*Store) Get ¶
Get returns the KVPair associated with key. If the key does not exist, it returns an error wrapping ErrNotExist.
func (*Store) GetAll ¶
GetAll returns all KVPairs with keys matching the given pattern. The pattern syntax is the same as path.Match. Returns an empty slice (not an error) if no keys match.
func (*Store) GetAllValues ¶
GetAllValues returns all values for keys matching the given pattern. The pattern syntax is the same as path.Match. Returns an empty slice (not an error) if no keys match.
func (*Store) GetValue ¶
GetValue returns the value associated with key. If the key does not exist and a default is provided, the default is returned. Otherwise, it returns an error wrapping ErrNotExist.
func (*Store) List ¶
List returns all entry names directly under the given path. This includes both leaf keys and intermediate path components.