store 過期、向量與型別
最後更新
本頁列出
core/store 的過期與向量方法,以及公開的 Entry、ValueType、AOFRecord 型別。過期
- func (c *core) TTL(key string) int64
- func (c *core) Expire(key string, seconds int64) error
- func (c *core) ExpireAt(key string, timestamp int64) error
- func (c *core) Persist(key string) error
TTL 在不存在或已過期時回傳 -2,無過期時回傳 -1。向量
- var ErrNoEmbedder = errors.New("no embedder: OPENAI_API_KEY not provided")
- func (c *core) VSearch(ctx context.Context, text, pattern string, k int) ([]string, error)
- func (c *core) VSim(key1, key2 string) (float64, error)
- func (c *core) VGet(key string) ([]float32, bool)
Entry 與紀錄型別
- type Entry struct {
- Key string `json:"key"`
- Type ValueType `json:"type"`
- CreatedAt int64 `json:"created_at"`
- UpdatedAt *int64 `json:"updated_at,omitempty"`
- ExpireAt *int64 `json:"expire_at,omitempty"`
- Vector []float32 `json:"vector,omitempty"`
- }
- func (e *Entry) Value() string
- type ValueType int
- const (
- TypeJSON ValueType = iota
- TypeString
- TypeInt
- TypeFloat
- TypeBool
- TypeDate
- )
- func (t ValueType) String() string
- type AOFRecord struct {
- Timestamp int64 `json:"ts"`
- Command string `json:"cmd"`
- Key string `json:"key"`
- Value string `json:"value,omitempty"`
- ExpireAt *int64 `json:"expire_at,omitempty"`
- Vector *string `json:"vector,omitempty"`
- }