Documentation
¶
Index ¶
- func ComputeFingerprint(content string) string
- type CacheStats
- type CacheStrategy
- type CachedResult
- type FingerprintCache
- func (fc *FingerprintCache) Clear()
- func (fc *FingerprintCache) Get(content string) *FingerprintResult
- func (fc *FingerprintCache) GetByFingerprint(fp string) *FingerprintResult
- func (fc *FingerprintCache) Prune() int
- func (fc *FingerprintCache) Set(content string, compressed string, tokensSaved int)
- func (fc *FingerprintCache) SetByFingerprint(fp string, original string, compressed string, tokensSaved int)
- func (fc *FingerprintCache) Size() int
- func (fc *FingerprintCache) Stats() CacheStats
- type FingerprintResult
- type LRUCache
- type LRUStats
- type MultiLayerCache
- type StringCacheItem
- type StringFIFOCache
- type StringLFUCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeFingerprint ¶
ComputeFingerprint generates a SHA-256 hash of the content
Types ¶
type CacheStats ¶
CacheStats holds cache statistics
type CacheStrategy ¶
type CacheStrategy string
const ( StrategyLRU CacheStrategy = "lru" StrategyLFU CacheStrategy = "lfu" StrategyFIFO CacheStrategy = "fifo" )
type CachedResult ¶
type CachedResult struct {
Fingerprint string
OriginalSize int
Compressed string
CompressedSize int
TokensSaved int
CreatedAt time.Time
ExpiresAt time.Time
AccessCount int64 // accessed atomically
}
CachedResult holds a cached compression result
type FingerprintCache ¶
type FingerprintCache struct {
// contains filtered or unexported fields
}
FingerprintCache implements content-based caching using SHA-256 fingerprints. T35: Cache by content hash, not full content - enables: 1. Deduplication of identical outputs 2. Fast cache lookups for repeated content 3. Memory-efficient caching (hash keys vs full content)
func GetGlobalCache ¶
func GetGlobalCache() *FingerprintCache
GetGlobalCache returns the global fingerprint cache
func NewFingerprintCache ¶
func NewFingerprintCache(maxEntries int, ttl time.Duration) *FingerprintCache
NewFingerprintCache creates a new fingerprint-based cache
func (*FingerprintCache) Get ¶
func (fc *FingerprintCache) Get(content string) *FingerprintResult
Get retrieves a cached result by content fingerprint
func (*FingerprintCache) GetByFingerprint ¶
func (fc *FingerprintCache) GetByFingerprint(fp string) *FingerprintResult
GetByFingerprint retrieves a cached result by fingerprint
func (*FingerprintCache) Prune ¶
func (fc *FingerprintCache) Prune() int
Prune removes expired entries
func (*FingerprintCache) Set ¶
func (fc *FingerprintCache) Set(content string, compressed string, tokensSaved int)
Set stores a result in the cache
func (*FingerprintCache) SetByFingerprint ¶
func (fc *FingerprintCache) SetByFingerprint(fp string, original string, compressed string, tokensSaved int)
SetByFingerprint stores a result with a known fingerprint
func (*FingerprintCache) Size ¶
func (fc *FingerprintCache) Size() int
Size returns the number of entries in the cache
func (*FingerprintCache) Stats ¶
func (fc *FingerprintCache) Stats() CacheStats
Stats returns cache statistics
type FingerprintResult ¶
type FingerprintResult struct {
Hash string
Hit bool
Cached *CachedResult
}
FingerprintResult holds the result of a fingerprint operation
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRUCache provides a thread-safe LRU cache with TTL support. Uses interface{} for values to support different result types.
func NewLRUCache ¶
NewLRUCache creates an LRU cache with given max size and TTL.
type MultiLayerCache ¶
type MultiLayerCache struct {
// contains filtered or unexported fields
}
func NewMultiLayerCache ¶
func NewMultiLayerCache(maxSize int) *MultiLayerCache
func (*MultiLayerCache) Delete ¶
func (c *MultiLayerCache) Delete(key string)
func (*MultiLayerCache) SetString ¶
func (c *MultiLayerCache) SetString(key, value string)
func (*MultiLayerCache) Stats ¶
func (c *MultiLayerCache) Stats() map[string]interface{}
type StringCacheItem ¶
type StringCacheItem struct {
// contains filtered or unexported fields
}
type StringFIFOCache ¶
type StringFIFOCache struct {
// contains filtered or unexported fields
}
func NewStringFIFOCache ¶
func NewStringFIFOCache(capacity int) *StringFIFOCache
func (*StringFIFOCache) Delete ¶
func (c *StringFIFOCache) Delete(key string)
func (*StringFIFOCache) Len ¶
func (c *StringFIFOCache) Len() int
func (*StringFIFOCache) Set ¶
func (c *StringFIFOCache) Set(key, value string)
type StringLFUCache ¶
type StringLFUCache struct {
// contains filtered or unexported fields
}
func NewStringLFUCache ¶
func NewStringLFUCache(capacity int) *StringLFUCache
func (*StringLFUCache) Delete ¶
func (c *StringLFUCache) Delete(key string)
func (*StringLFUCache) Len ¶
func (c *StringLFUCache) Len() int
func (*StringLFUCache) Set ¶
func (c *StringLFUCache) Set(key, value string)