v0.7.0

store Package

Last updated


This page lists the core/store functions for opening a store, writing values, and reading or scanning keys.

Lifecycle and Sessions


  1. func New(dir string, apiKey ...string) (*Store, error)
  2. func (s *Store) Session() *Session
  3. func (s *Store) Close() error

Store and Session both embed the unexported core, so every method below is available on both.
  1. func (c *core) Current() int
  2. func (c *core) Select(index int) error
  3. func (c *core) HasEmbedder() bool
  4. func (c *core) Exec(input string) string
  5. func (c *core) DB() *db

DB returns the currently selected database, replaying it from disk on first use; its type is unexported, so outside the package the result is only an opaque handle.

Writes


  1. type SetFlag int
  2. const (
  3. SetDefault SetFlag = iota
  4. SetNX
  5. SetXX
  6. )
  7. func (c *core) Set(key, value string, flag SetFlag, expireAt *int64) error
  8. func (c *core) SetVector(ctx context.Context, key, value string, flag SetFlag, expireAt *int64) error
  9. func (c *core) SetField(key string, subKeys []string, value string, flag SetFlag, expireAt *int64) error
  10. func (c *core) Incr(key string, delta float64) (float64, error)
  11. func (c *core) IncrField(key string, subKeys []string, delta float64) (float64, error)
  12. func (c *core) Del(keys ...string) int
  13. func (c *core) DelField(key string, subKeys []string) error

Reads and Scans


  1. func (c *core) Get(key string) (*Entry, bool)
  2. func (c *core) GetField(key string, subKeys []string) (string, bool)
  3. func (c *core) Exist(key string) string
  4. func (c *core) ExistField(key string, subKeys []string) string
  5. func (c *core) Type(key string) string
  6. func (c *core) TypeField(key string, subKeys []string) string
  7. func (c *core) Keys(pattern string) []string
  8. func (c *core) Find(op filter.Operator, value string, limit int) []string
  9. func (c *core) Query(f filter.Filter, limit int) []string

Exist, ExistField, Type, and TypeField return the REPL text forms. Query returns key: value strings. limit <= 0 means no limit.

中文