Versions in this module Expand all Collapse all v0 v0.4.0 Feb 24, 2026 v0.3.0 Feb 23, 2026 v0.2.0 Feb 14, 2026 Changes in this version + var ErrCacheFull = errors.New("cache is full") + var ErrKeyTooLarge = errors.New("key exceeds maximum size") + var ErrNotFound = errors.New("key not found") + var ErrValueTooLarge = errors.New("value exceeds maximum size") + func CacheKey(prefix string, pattern *DetectedPattern) string + func CacheKeyForChunks(prefix string, chunks []types.Chunk) string + func CacheKeyForQuery(prefix, query string, topK int) string + func CacheKeyForText(prefix, text string) string + func HashChunks(chunks []types.Chunk) string + func HashText(text string) string + type Cache interface + Clear func(ctx context.Context) error + Close func() error + Delete func(ctx context.Context, key string) error + Get func(ctx context.Context, key string) ([]byte, error) + Has func(ctx context.Context, key string) bool + Set func(ctx context.Context, key string, value []byte, ttl time.Duration) error + Stats func() Stats + type Config struct + CleanupInterval time.Duration + DefaultTTL time.Duration + MaxSize int64 + MaxSizeBytes int64 + func DefaultConfig() Config + type DetectedPattern struct + Hash string + Metadata map[string]string + Text string + Type PatternType + type Entry struct + CreatedAt time.Time + ExpiresAt time.Time + Key string + Size int64 + Value []byte + func (e Entry) IsExpired() bool + type MemoryCache struct + func NewMemoryCache(cfg Config) *MemoryCache + func (c *MemoryCache) Clear(ctx context.Context) error + func (c *MemoryCache) Close() error + func (c *MemoryCache) Delete(ctx context.Context, key string) error + func (c *MemoryCache) Get(ctx context.Context, key string) ([]byte, error) + func (c *MemoryCache) Has(ctx context.Context, key string) bool + func (c *MemoryCache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error + func (c *MemoryCache) Stats() Stats + type PatternDetector struct + MinLength int + SystemPromptPrefixes []string + ToolDefinitionMarkers []string + func NewPatternDetector() *PatternDetector + func (d *PatternDetector) DetectChunkPatterns(chunks []types.Chunk) []DetectedPattern + func (d *PatternDetector) DetectPattern(text string) *DetectedPattern + type PatternType string + const PatternTypeCode + const PatternTypeDocument + const PatternTypeSystem + const PatternTypeTool + const PatternTypeUnknown + type RedisCache struct + func NewRedisCache(cfg RedisConfig) (*RedisCache, error) + func (c *RedisCache) Clear(ctx context.Context) error + func (c *RedisCache) Close() error + func (c *RedisCache) Delete(ctx context.Context, key string) error + func (c *RedisCache) Get(ctx context.Context, key string) ([]byte, error) + func (c *RedisCache) GetTTL(ttl time.Duration) time.Duration + func (c *RedisCache) Has(ctx context.Context, key string) bool + func (c *RedisCache) PrefixKey(key string) string + func (c *RedisCache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error + func (c *RedisCache) Stats() Stats + type RedisConfig struct + DB int + DefaultTTL time.Duration + DialTimeout time.Duration + KeyPrefix string + Password string + PoolSize int + ReadTimeout time.Duration + URL string + WriteTimeout time.Duration + func DefaultRedisConfig() RedisConfig + type Stats struct + Deletes int64 + Evictions int64 + Expirations int64 + Hits int64 + MaxSize int64 + MaxSizeBytes int64 + Misses int64 + Sets int64 + Size int64 + SizeBytes int64 + func (s Stats) HitRate() float64