Documentation
¶
Index ¶
- Variables
- type Cache
- func (c *Cache) Clear(projectName string) error
- func (c *Cache) Close() error
- func (c *Cache) ExportToJSON(w io.Writer, projectName string) error
- func (c *Cache) Get(prompt, model string, temperature float64, maxTokens int) (*Entry, error)
- func (c *Cache) GetHistory(limit int, projectName string) ([]Entry, error)
- func (c *Cache) GetStats(projectName string) ([]StatsEntry, error)
- func (c *Cache) ImportFromJSON(r io.Reader) error
- func (c *Cache) Set(entry *Entry) error
- type Config
- type Entry
- type StatsEntry
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 AI response caching in SQLite
func (*Cache) ExportToJSON ¶
ExportToJSON exports cache entries to JSON
func (*Cache) GetHistory ¶
GetHistory retrieves recent AI interactions
func (*Cache) GetStats ¶
func (c *Cache) GetStats(projectName string) ([]StatsEntry, error)
GetStats retrieves aggregated statistics
func (*Cache) ImportFromJSON ¶
ImportFromJSON imports cache entries from JSON
type Config ¶
type Config struct {
DBPath string // Database file path (default: ~/.cache/clicky-ai.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 {
// Pointer (8 bytes)
ExpiresAt *time.Time
// Strings (16 bytes each on 64-bit)
CacheKey string
PromptHash string
Model string
Prompt string
Response string
Error string
ProjectName string
TaskName string
SessionID string
// 8-byte types
ID int64
DurationMS int64
CostUSD float64
Temperature float64
CreatedAt time.Time
AccessedAt time.Time
// 4-byte types
TokensInput int
TokensOutput int
TokensCacheRead int
TokensCacheWrite int
TokensTotal int
MaxTokens int
}
Entry represents a cached AI response
type StatsEntry ¶
type StatsEntry struct {
// Strings (16 bytes each)
Model string
ProjectName string
// 8-byte types
TotalRequests int64
SuccessfulRequests int64
FailedRequests int64
TotalTokens int64
AvgDurationMS int64
TotalCost float64
FirstRequest time.Time
LastRequest time.Time
}
StatsEntry represents aggregated statistics
Click to show internal directories.
Click to hide internal directories.