Documentation
¶
Overview ¶
Package inmem provides a concurrency-safe, process-local implementation of cache.Store. The zero Store value is ready to use.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps embedding cache entries in process memory. It is safe for concurrent use, and its zero value is ready to use.
func New ¶
func New() *Store
New constructs an empty Store.
Example ¶
package main
import (
"context"
"fmt"
"github.com/dotcommander/reliquary/embedding"
"github.com/dotcommander/reliquary/embedding/cache"
"github.com/dotcommander/reliquary/embedding/cache/inmem"
)
func main() {
store := inmem.New()
entry := cache.Entry{
Model: embedding.ModelRef{Name: "example", Dim: 2},
Vector: embedding.Vector{1, 2},
}
if err := store.Set(context.Background(), "key", entry); err != nil {
panic(err)
}
got, ok, err := store.Get(context.Background(), "key")
fmt.Println(ok, err == nil, got.Model.Name, got.Vector)
}
Output: true true example [1 2]
Click to show internal directories.
Click to hide internal directories.