cache

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAll

func ApplyAll(cfg *config.Config, cmd *cli.Command)

ApplyAll calls Apply on all registered plugins that define one.

func Names

func Names() []string

Names returns all registered cache plugin names.

func PluginFlags

func PluginFlags(cfg *config.Config) []cli.Flag

PluginFlags returns CLI flags contributed by all registered cache plugins.

func Register

func Register(p Plugin)

Register adds a cache plugin.

func WithEntriesCacheContext

func WithEntriesCacheContext(ctx context.Context, c MemoryEntriesCache) context.Context

WithEntriesCacheContext returns a new context carrying the given MemoryEntriesCache.

Types

type CachedMemoryEntries

type CachedMemoryEntries struct {
	Entries []model.Entry
	Epoch   *int64
}

CachedMemoryEntries holds cached context entries for a conversation/client pair.

type Loader

type Loader func(ctx context.Context) (MemoryEntriesCache, error)

Loader creates a cache from config.

func Select

func Select(name string) (Loader, error)

Select returns the loader for the named cache plugin.

type MemoryEntriesCache

type MemoryEntriesCache interface {
	Available() bool
	Get(ctx context.Context, conversationID uuid.UUID, clientID string) (*CachedMemoryEntries, error)
	Set(ctx context.Context, conversationID uuid.UUID, clientID string, entries CachedMemoryEntries, ttl time.Duration) error
	Remove(ctx context.Context, conversationID uuid.UUID, clientID string) error
}

MemoryEntriesCache caches context entries for sync operations.

func EntriesCacheFromContext

func EntriesCacheFromContext(ctx context.Context) MemoryEntriesCache

EntriesCacheFromContext retrieves the MemoryEntriesCache from the context. Returns nil if none was set.

type Plugin

type Plugin struct {
	Name   string
	Loader Loader
	Flags  func(cfg *config.Config) []cli.Flag
	Apply  func(cfg *config.Config, cmd *cli.Command)
}

Plugin represents a cache plugin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL