store 套件
最後更新
本頁列出 core/store 中開啟 store、寫入值,以及讀取與掃描鍵的函式。
生命週期與 Session
func New(dir string, apiKey ...string) (*Store, error)
func (s *Store) Session() *Session
func (s *Store) Close() error
Store 與 Session 都內嵌未導出的 core,因此下列方法兩者皆可用。
func (c *core) Current() int
func (c *core) Select(index int) error
func (c *core) HasEmbedder() bool
func (c *core) Exec(input string) string
寫入
type SetFlag int
const (
SetDefault SetFlag = iota
SetNX
SetXX
)
func (c *core) Set(key, value string, flag SetFlag, expireAt *int64) error
func (c *core) SetVector(ctx context.Context, key, value string, flag SetFlag, expireAt *int64) error
func (c *core) SetField(key string, subKeys []string, value string, flag SetFlag, expireAt *int64) error
func (c *core) Incr(key string, delta float64) (float64, error)
func (c *core) IncrField(key string, subKeys []string, delta float64) (float64, error)
func (c *core) Del(keys ...string) int
func (c *core) DelField(key string, subKeys []string) error
讀取與掃描
func (c *core) Get(key string) (*Entry, bool)
func (c *core) GetField(key string, subKeys []string) (string, bool)
func (c *core) Exist(key string) string
func (c *core) ExistField(key string, subKeys []string) string
func (c *core) Type(key string) string
func (c *core) TypeField(key string, subKeys []string) string
func (c *core) Keys(pattern string) []string
func (c *core) Find(op filter.Operator, value string, limit int) []string
func (c *core) Query(f filter.Filter, limit int) []string
Exist、ExistField、Type、TypeField 回傳 REPL 文字形式。Query 回傳 key: value 字串。limit <= 0 代表不限制。