v0.7.0

store Expiration, Vectors, and Types

Last updated


This page lists the core/store expiration and vector methods and the exported Entry, ValueType, and AOFRecord types.

Expiration


  1. func (c *core) TTL(key string) int64
  2. func (c *core) Expire(key string, seconds int64) error
  3. func (c *core) ExpireAt(key string, timestamp int64) error
  4. func (c *core) Persist(key string) error

TTL returns -2 when missing or expired and -1 without expiry.

Vectors


  1. var ErrNoEmbedder = errors.New("no embedder: OPENAI_API_KEY not provided")
  2. func (c *core) VSearch(ctx context.Context, text, pattern string, k int) ([]string, error)
  3. func (c *core) VSim(key1, key2 string) (float64, error)
  4. func (c *core) VGet(key string) ([]float32, bool)

Entry and Record Types


  1. type Entry struct {
  2. Key string `json:"key"`
  3. Type ValueType `json:"type"`
  4. CreatedAt int64 `json:"created_at"`
  5. UpdatedAt *int64 `json:"updated_at,omitempty"`
  6. ExpireAt *int64 `json:"expire_at,omitempty"`
  7. Vector []float32 `json:"vector,omitempty"`
  8. }
  9. func (e *Entry) Value() string
  10. type ValueType int
  11. const (
  12. TypeJSON ValueType = iota
  13. TypeString
  14. TypeInt
  15. TypeFloat
  16. TypeBool
  17. TypeDate
  18. )
  19. func (t ValueType) String() string
  20. type AOFRecord struct {
  21. Timestamp int64 `json:"ts"`
  22. Command string `json:"cmd"`
  23. Key string `json:"key"`
  24. Value string `json:"value,omitempty"`
  25. ExpireAt *int64 `json:"expire_at,omitempty"`
  26. Vector *string `json:"vector,omitempty"`
  27. }


中文