Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCacheDisabled indicates caching is disabled ErrCacheDisabled = errors.New("caching is disabled") // ErrNotFound indicates the entry was not found in cache ErrNotFound = errors.New("cache entry not found") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache manages LLM response caching in SQLite
func (*Cache) GetStats ¶
func (c *Cache) GetStats() ([]StatsEntry, error)
GetStats retrieves aggregated statistics
type Config ¶
type Config struct {
DBPath string // Database file path (default: ~/.cache/commons-llm.db)
TTL time.Duration // Cache time-to-live
NoCache bool // Disable caching
Debug bool // Enable debug output
}
Config holds cache configuration
type Entry ¶
type Entry struct {
ID int64
CacheKey string
PromptHash string
Model string
Prompt string
Response string
Error string
TokensInput int
TokensOutput int
TokensReasoning int
TokensCacheRead int
TokensCacheWrite int
TokensTotal int
CostUSD float64
DurationMS int64
Provider string
Temperature float64
MaxTokens int
CreatedAt time.Time
AccessedAt time.Time
ExpiresAt *time.Time
}
Entry represents a cached LLM response
type StatsEntry ¶
type StatsEntry struct {
Model string
Provider string
TotalRequests int64
CacheHits int64
CacheMisses int64
ErrorCount int64
TotalInputTokens int64
TotalOutputTokens int64
TotalReasoningTokens int64
TotalCacheReadTokens int64
TotalCacheWriteTokens int64
TotalCost float64
AvgDurationMS int64
FirstRequest time.Time
LastRequest time.Time
}
StatsEntry represents aggregated statistics
Click to show internal directories.
Click to hide internal directories.