Documentation
¶
Overview ¶
internal/cache/backup.go
internal/cache/config_api.go
internal/cache/consistency.go
internal/cache/cost_optimizer.go
internal/cache/debug.go
internal/cache/geo_cache.go
internal/cache/patterns.go
internal/cache/prefetch.go
internal/cache/recovery.go
internal/cache/tiered_cache.go
internal/cache/time_strategies.go
internal/cache/user_cache.go
Index ¶
- type AccessPattern
- type AccessPatternAnalysis
- type BackupInfo
- type BackupItem
- type BackupManifest
- type BackupSchedule
- type BackupType
- type CacheConfig
- type CacheDebugger
- func (d *CacheDebugger) DumpCache() map[string]string
- func (d *CacheDebugger) Enable()
- func (d *CacheDebugger) GetCacheStats() map[string]interface{}
- func (d *CacheDebugger) GetSlowOperations(threshold time.Duration) []*OperationTrace
- func (d *CacheDebugger) TraceOperation(op string, key string, size int64, duration time.Duration, hit bool, err error)
- type CacheItem
- type CacheManager
- type CacheStats
- type CacheValue
- type CacheVersion
- type CacheWarmer
- type ClusterNode
- type ClusteredCache
- type CompressionStats
- type Config
- type ConfigAPI
- type ConsistencyLevel
- type ConsistencyManager
- type CostOptimizer
- type DedupBlock
- type DeduplicationStats
- type DemotionPolicy
- type EdgeNode
- type EvictionPolicy
- type FailoverStatus
- type GeoCacheManager
- type GeoLocation
- type HotDataTracker
- type HourlyPattern
- type IntegrityReport
- type InvalidationAPI
- type JournalOperation
- type LFUPolicy
- type LRU
- func (c *LRU) Clear()
- func (c *LRU) Delete(ctx context.Context, container, artifact string) error
- func (c *LRU) Get(ctx context.Context, container, artifact string) (io.Reader, bool, error)
- func (c *LRU) Put(ctx context.Context, container, artifact string, reader io.Reader, size int64) error
- func (c *LRU) Stats() *CacheStats
- type LRUPolicy
- type MetricsTracker
- func (m *MetricsTracker) GetHitRate() float64
- func (m *MetricsTracker) GetTopKeys(n int) []string
- func (m *MetricsTracker) RecordHit(key string, latency time.Duration, bytes int64)
- func (m *MetricsTracker) RecordMiss(key string, latency time.Duration)
- func (m *MetricsTracker) RecordPut(key string, latency time.Duration, bytes int64)
- type OperationTrace
- type PatternAnalyzer
- type PerformanceMetrics
- type PerformanceMonitor
- type PersistentCache
- type PredictivePrefetcher
- type PrefetchStrategy
- type PromotionPolicy
- type RecoveryJournal
- type RecoveryReport
- type RecoveryStatus
- type ReplicationConfig
- type ReplicationMode
- type SSDCache
- func (c *SSDCache) ApplyDemotionPolicy()
- func (c *SSDCache) CheckIntegrity() (*IntegrityReport, error)
- func (c *SSDCache) CleanOrphanedFiles() (*IntegrityReport, error)
- func (c *SSDCache) CreateBackup(backupDir string, backupType BackupType) (*BackupInfo, error)
- func (c *SSDCache) CreateEncryptedBackup(backupDir string, backupType BackupType, encryptionKey []byte) (*BackupInfo, error)
- func (c *SSDCache) CreateIncrementalBackup(backupDir string, baseBackupID string) (*BackupInfo, error)
- func (c *SSDCache) Delete(key string) error
- func (c *SSDCache) EnableCompression(algorithm string)
- func (c *SSDCache) EnableDeduplication()
- func (c *SSDCache) EnableEncryption(key []byte) error
- func (c *SSDCache) EnableMonitoring()
- func (c *SSDCache) ExportToJSON(path string) error
- func (c *SSDCache) Get(key string) ([]byte, bool)
- func (c *SSDCache) GetCompressionStats() *CompressionStats
- func (c *SSDCache) GetDeduplicationStats() *DeduplicationStats
- func (c *SSDCache) GetFailoverStatus() FailoverStatus
- func (c *SSDCache) GetLastRecoveryReport() *RecoveryReport
- func (c *SSDCache) GetMemoryKeys() []string
- func (c *SSDCache) GetPerformanceMetrics() *PerformanceMetrics
- func (c *SSDCache) GetShardForKey(key string) int
- func (c *SSDCache) GetWriteStats() map[string]interface{}
- func (c *SSDCache) ImportFromJSON(path string) (int, error)
- func (c *SSDCache) IsHot(key string) bool
- func (c *SSDCache) IsUsingSecondary() bool
- func (c *SSDCache) Put(key string, data []byte) error
- func (c *SSDCache) RecoverIndex() (int, error)
- func (c *SSDCache) RepairCorruption(report *IntegrityReport) (int, error)
- func (c *SSDCache) RestoreFromBackup(backupDir string, backupID string) error
- func (c *SSDCache) RotateEncryptionKey(newKey []byte) error
- func (c *SSDCache) SetDemotionPolicy(policy *DemotionPolicy)
- func (c *SSDCache) SetPromotionPolicy(policy *PromotionPolicy)
- func (c *SSDCache) SimulateFailure()
- func (c *SSDCache) StartBackupScheduler(schedule *BackupSchedule) error
- func (c *SSDCache) Stats() map[string]interface{}
- func (c *SSDCache) StopBackupScheduler()
- func (c *SSDCache) ValidateBackup(backupDir string, backupID string) (bool, error)
- type SSDEntry
- type SequentialPrefetchStrategy
- type SizedCacheItem
- type SizedCacheStats
- type SizedLRU
- func (c *SizedLRU) Delete(ctx context.Context, container, artifact string) error
- func (c *SizedLRU) Get(ctx context.Context, container, artifact string) (io.Reader, bool, error)
- func (c *SizedLRU) Put(ctx context.Context, container, artifact string, reader io.Reader, size int64) error
- func (c *SizedLRU) Stats() *SizedCacheStats
- type StorageTier
- type TieredCache
- type TimeBasedStrategy
- type UserAwareCacheManager
- type UserCacheProfile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessPattern ¶
AccessPattern tracks access patterns for cache items
type AccessPatternAnalysis ¶
type AccessPatternAnalysis struct {
Key string
AccessCount int64
LastAccess time.Time
AccessInterval time.Duration
Predictability float64 // 0-1 score
}
AccessPattern represents analyzed access patterns
type BackupInfo ¶
type BackupInfo struct {
ID string `json:"id"`
Type BackupType `json:"type"`
Timestamp time.Time `json:"timestamp"`
ItemCount int `json:"item_count"`
Size int64 `json:"size"`
Encrypted bool `json:"encrypted"`
BaseBackupID string `json:"base_backup_id,omitempty"`
Checksum string `json:"checksum"`
CacheStats map[string]interface{} `json:"cache_stats"`
}
BackupInfo contains metadata about a backup
type BackupItem ¶
type BackupItem struct {
Key string `json:"key"`
Size int64 `json:"size"`
Checksum string `json:"checksum"`
Timestamp time.Time `json:"timestamp"`
Offset int64 `json:"offset"`
}
BackupItem represents a single item in the backup
type BackupManifest ¶
type BackupManifest struct {
Info *BackupInfo `json:"info"`
Items []BackupItem `json:"items"`
Version int `json:"version"`
}
BackupManifest contains the backup metadata and item list
type BackupSchedule ¶
type BackupSchedule struct {
Enabled bool
Interval time.Duration
BackupDir string
Type BackupType
MaxBackups int
OnSuccess func(*BackupInfo)
OnError func(error)
// contains filtered or unexported fields
}
BackupSchedule defines automatic backup configuration
type BackupType ¶
type BackupType string
BackupType defines the type of backup
const ( BackupTypeFull BackupType = "full" BackupTypeIncremental BackupType = "incremental" )
type CacheConfig ¶
type CacheConfig struct {
// Size limits
MemorySize int64 `json:"memory_size"`
SSDSize int64 `json:"ssd_size"`
// Performance tuning
CompressionEnabled bool `json:"compression_enabled"`
CompressionAlgo string `json:"compression_algo"`
EncryptionEnabled bool `json:"encryption_enabled"`
DeduplicationOn bool `json:"deduplication_on"`
// Eviction policy
EvictionPolicy string `json:"eviction_policy"`
TTL time.Duration `json:"ttl"`
// Advanced features
PrefetchEnabled bool `json:"prefetch_enabled"`
ConsistencyLevel string `json:"consistency_level"`
DebugMode bool `json:"debug_mode"`
}
CacheConfig represents runtime cache configuration
type CacheDebugger ¶
type CacheDebugger struct {
// contains filtered or unexported fields
}
CacheDebugger provides debugging tools for cache inspection
func NewCacheDebugger ¶
func NewCacheDebugger(cache *SSDCache) *CacheDebugger
NewCacheDebugger creates a cache debugging tool
func (*CacheDebugger) DumpCache ¶
func (d *CacheDebugger) DumpCache() map[string]string
DumpCache returns a snapshot of cache contents
func (*CacheDebugger) GetCacheStats ¶
func (d *CacheDebugger) GetCacheStats() map[string]interface{}
GetCacheStats returns current cache statistics
func (*CacheDebugger) GetSlowOperations ¶
func (d *CacheDebugger) GetSlowOperations(threshold time.Duration) []*OperationTrace
GetSlowOperations returns operations slower than threshold
func (*CacheDebugger) TraceOperation ¶
func (d *CacheDebugger) TraceOperation(op string, key string, size int64, duration time.Duration, hit bool, err error)
TraceOperation records a cache operation
type CacheItem ¶
type CacheItem struct {
Container string
Artifact string
Data []byte
Size int64
LastAccessed time.Time
}
CacheItem represents a single cached artifact
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager combines all cache features
func NewCacheManager ¶
func NewCacheManager(maxBytes int64) *CacheManager
NewCacheManager creates a fully-featured cache
type CacheStats ¶
CacheStats holds cache statistics
func (*CacheStats) HitRate ¶
func (s *CacheStats) HitRate() float64
HitRate calculates the cache hit rate
type CacheValue ¶
type CacheValue struct {
Key string
Size int64
AccessCount int64
LastAccess time.Time
StorageCost float64
AccessSavings float64
NetValue float64
}
CacheValue represents the value/cost analysis of cached data
type CacheVersion ¶
type CacheVersion struct {
Key string
Version int64
Timestamp time.Time
Checksum string
Source string
}
CacheVersion tracks cache entry versions
type CacheWarmer ¶
type CacheWarmer struct {
// contains filtered or unexported fields
}
Step 204: Cache Warming
func (*CacheWarmer) WarmCache ¶
func (w *CacheWarmer) WarmCache(keys []string) error
WarmCache loads frequently accessed items on startup
type ClusterNode ¶
Step 208: Cache Clustering (simplified)
type ClusteredCache ¶
type ClusteredCache struct {
// contains filtered or unexported fields
}
type CompressionStats ¶
type CompressionStats struct {
OriginalSize int64
CompressedSize int64
BytesSaved int64
CompressionRatio float64
}
CompressionStats tracks compression effectiveness
type ConfigAPI ¶
type ConfigAPI struct {
// contains filtered or unexported fields
}
ConfigAPI provides runtime configuration management
func NewConfigAPI ¶
NewConfigAPI creates a configuration API
func (*ConfigAPI) GetConfig ¶
func (api *ConfigAPI) GetConfig() *CacheConfig
GetConfig returns current configuration
func (*ConfigAPI) RegisterChangeListener ¶
func (api *ConfigAPI) RegisterChangeListener(callback func(*CacheConfig))
RegisterChangeListener adds a config change callback
func (*ConfigAPI) UpdateConfig ¶
UpdateConfig applies new configuration
func (*ConfigAPI) ValidateConfig ¶
func (api *ConfigAPI) ValidateConfig(config *CacheConfig) []string
ValidateConfig checks if configuration is valid
type ConsistencyLevel ¶
type ConsistencyLevel int
ConsistencyLevel defines cache consistency guarantees
const ( EventualConsistency ConsistencyLevel = iota StrongConsistency BoundedStaleness )
type ConsistencyManager ¶
type ConsistencyManager struct {
// contains filtered or unexported fields
}
ConsistencyManager ensures cache consistency across nodes
func NewConsistencyManager ¶
func NewConsistencyManager(level ConsistencyLevel) *ConsistencyManager
NewConsistencyManager creates a consistency controller
func (*ConsistencyManager) Invalidate ¶
func (c *ConsistencyManager) Invalidate(key string)
Invalidate marks cache entry as invalid
func (*ConsistencyManager) UpdateVersion ¶
func (c *ConsistencyManager) UpdateVersion(key string, version int64, checksum string)
UpdateVersion updates the version info for a key
func (*ConsistencyManager) ValidateConsistency ¶
func (c *ConsistencyManager) ValidateConsistency(key string, localVersion int64) bool
ValidateConsistency checks if cached data is consistent
type CostOptimizer ¶
type CostOptimizer struct {
// contains filtered or unexported fields
}
CostOptimizer optimizes cache usage based on cost/benefit
func NewCostOptimizer ¶
func NewCostOptimizer(budget float64) *CostOptimizer
NewCostOptimizer creates a cost-aware cache optimizer
func (*CostOptimizer) AnalyzeValue ¶
func (c *CostOptimizer) AnalyzeValue(key string, size int64, accessCount int64) *CacheValue
AnalyzeValue calculates the value of caching specific data
func (*CostOptimizer) GetOptimalTier ¶
func (c *CostOptimizer) GetOptimalTier(accessFreq float64, size int64) *StorageTier
GetOptimalTier returns the most cost-effective tier for data
func (*CostOptimizer) ShouldCache ¶
func (c *CostOptimizer) ShouldCache(key string, size int64, predictedAccess int64) bool
ShouldCache determines if data is worth caching based on cost
type DedupBlock ¶
DedupBlock represents a deduplicated data block
type DeduplicationStats ¶
DeduplicationStats tracks deduplication effectiveness
type DemotionPolicy ¶
type DemotionPolicy struct {
MaxAge time.Duration // Max time in memory without access
LowWaterMark int64 // Start demotion when memory usage exceeds this
HighWaterMark int64 // Aggressively demote when exceeding this
}
DemotionPolicy defines when to demote data from memory to SSD
type EdgeNode ¶
type EdgeNode struct {
ID string
Location GeoLocation
Capacity int64
Load float64
Latency time.Duration
Active bool
}
EdgeNode represents a cache edge node
type EvictionPolicy ¶
Step 206: Cache Eviction Policies
type FailoverStatus ¶
type FailoverStatus string
FailoverStatus represents failover state
const ( FailoverStatusActive FailoverStatus = "active" FailoverStatusInactive FailoverStatus = "inactive" )
type GeoCacheManager ¶
type GeoCacheManager struct {
// contains filtered or unexported fields
}
GeoCacheManager manages geographically distributed caching
func NewGeoCacheManager ¶
func NewGeoCacheManager() *GeoCacheManager
NewGeoCacheManager creates a geo-aware cache manager
func (*GeoCacheManager) AddEdgeNode ¶
func (g *GeoCacheManager) AddEdgeNode(node *EdgeNode)
AddEdgeNode registers an edge cache node
func (*GeoCacheManager) FindNearestEdge ¶
func (g *GeoCacheManager) FindNearestEdge(userLoc GeoLocation) *EdgeNode
FindNearestEdge finds the closest edge node to a user
type GeoLocation ¶
type GeoLocation struct {
Latitude float64
Longitude float64
Region string
City string
Country string
}
GeoLocation represents a geographic location
type HotDataTracker ¶
type HotDataTracker struct {
// contains filtered or unexported fields
}
Step 205: Hot Data Identification
func (*HotDataTracker) IsHot ¶
func (h *HotDataTracker) IsHot(key string) bool
IsHot determines if data should be cached
func (*HotDataTracker) RecordAccess ¶
func (h *HotDataTracker) RecordAccess(key string)
RecordAccess updates access tracking
type HourlyPattern ¶
HourlyPattern tracks usage patterns by hour
type IntegrityReport ¶
type IntegrityReport struct {
TotalFiles int `json:"total_files"`
CorruptedFiles int `json:"corrupted_files"`
CorruptedKeys []string `json:"corrupted_keys"`
MissingFiles int `json:"missing_files"`
OrphanedFiles int `json:"orphaned_files"`
SpaceReclaimed int64 `json:"space_reclaimed"`
}
IntegrityReport contains results of integrity check
type InvalidationAPI ¶
type InvalidationAPI struct {
// contains filtered or unexported fields
}
Step 209: Cache Invalidation API
func (*InvalidationAPI) InvalidateAll ¶
func (api *InvalidationAPI) InvalidateAll() error
InvalidateAll clears entire cache
func (*InvalidationAPI) InvalidateKey ¶
func (api *InvalidationAPI) InvalidateKey(container, artifact string) error
InvalidateKey removes a specific key
func (*InvalidationAPI) InvalidatePattern ¶
func (api *InvalidationAPI) InvalidatePattern(pattern string) error
InvalidatePattern removes keys matching pattern
type JournalOperation ¶
type JournalOperation struct {
Type string `json:"type"`
Key string `json:"key"`
DataPath string `json:"data_path,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
JournalOperation represents a pending cache operation
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU implements a Least Recently Used cache
type MetricsTracker ¶
type MetricsTracker struct {
// contains filtered or unexported fields
}
MetricsTracker tracks detailed cache metrics
func NewMetricsTracker ¶
func NewMetricsTracker() *MetricsTracker
NewMetricsTracker creates a new metrics tracker
func (*MetricsTracker) GetHitRate ¶
func (m *MetricsTracker) GetHitRate() float64
GetHitRate returns overall hit rate
func (*MetricsTracker) GetTopKeys ¶
func (m *MetricsTracker) GetTopKeys(n int) []string
GetTopKeys returns the most accessed keys
func (*MetricsTracker) RecordHit ¶
func (m *MetricsTracker) RecordHit(key string, latency time.Duration, bytes int64)
RecordHit records a cache hit
func (*MetricsTracker) RecordMiss ¶
func (m *MetricsTracker) RecordMiss(key string, latency time.Duration)
RecordMiss records a cache miss
type OperationTrace ¶
type OperationTrace struct {
Timestamp time.Time
Operation string
Key string
Size int64
Duration time.Duration
Hit bool
Error error
StackTrace string
}
OperationTrace records cache operation details
type PatternAnalyzer ¶
type PatternAnalyzer struct {
// contains filtered or unexported fields
}
PatternAnalyzer tracks and analyzes access patterns
func NewPatternAnalyzer ¶
func NewPatternAnalyzer(window time.Duration) *PatternAnalyzer
NewPatternAnalyzer creates a pattern analyzer
func (*PatternAnalyzer) GetHotKeys ¶
func (p *PatternAnalyzer) GetHotKeys(limit int) []string
GetHotKeys returns the most frequently accessed keys
func (*PatternAnalyzer) GetPattern ¶
func (p *PatternAnalyzer) GetPattern(key string) *AccessPatternAnalysis
GetPattern returns the access pattern for a key
func (*PatternAnalyzer) TrackAccess ¶
func (p *PatternAnalyzer) TrackAccess(key string)
TrackAccess records an access to a key
type PerformanceMetrics ¶
type PerformanceMetrics struct {
// Latency tracking
PutLatencyP50 time.Duration
GetLatencyP50 time.Duration
// Operation counts
PutCount int64
GetCount int64
// Hit rate tracking
CacheHits int64
CacheMisses int64
HitRate float64
}
PerformanceMetrics tracks cache performance
type PerformanceMonitor ¶
type PerformanceMonitor struct {
// contains filtered or unexported fields
}
Step 210: Cache Performance Metrics
func (*PerformanceMonitor) GetP99Latency ¶
func (pm *PerformanceMonitor) GetP99Latency() time.Duration
GetP99Latency returns 99th percentile latency
type PersistentCache ¶
type PersistentCache struct {
*SizedLRU
// contains filtered or unexported fields
}
Step 207: Cache Persistence
func (*PersistentCache) LoadFromDisk ¶
func (p *PersistentCache) LoadFromDisk() error
LoadFromDisk restores cache from disk
func (*PersistentCache) SaveToDisk ¶
func (p *PersistentCache) SaveToDisk() error
SaveToDisk persists cache to disk
type PredictivePrefetcher ¶
type PredictivePrefetcher struct {
// contains filtered or unexported fields
}
PredictivePrefetcher handles intelligent prefetching
func NewPredictivePrefetcher ¶
func NewPredictivePrefetcher(analyzer *PatternAnalyzer, strategy PrefetchStrategy) *PredictivePrefetcher
NewPredictivePrefetcher creates a new prefetcher
func (*PredictivePrefetcher) TriggerPrefetch ¶
func (p *PredictivePrefetcher) TriggerPrefetch(key string)
TriggerPrefetch analyzes if prefetch should occur
type PrefetchStrategy ¶
type PrefetchStrategy interface {
ShouldPrefetch(key string, pattern *AccessPatternAnalysis) bool
GetPrefetchKeys(key string) []string
}
PrefetchStrategy defines how to predict and prefetch data
type PromotionPolicy ¶
type PromotionPolicy struct {
FrequencyThreshold int // Min accesses to trigger promotion
TimeWindow time.Duration // Time window for counting accesses
SizeLimit int64 // Max size to promote (avoid huge files in memory)
}
PromotionPolicy defines when to promote data from SSD to memory
type RecoveryJournal ¶
type RecoveryJournal struct {
Timestamp time.Time `json:"timestamp"`
Operations []JournalOperation `json:"operations"`
}
RecoveryJournal tracks pending operations for crash recovery
type RecoveryReport ¶
type RecoveryReport struct {
Status RecoveryStatus `json:"status"`
RecoveredItems int `json:"recovered_items"`
FailedItems int `json:"failed_items"`
Duration time.Duration `json:"duration"`
Errors []string `json:"errors"`
}
RecoveryReport contains recovery operation results
type RecoveryStatus ¶
type RecoveryStatus string
RecoveryStatus represents the status of a recovery operation
const ( RecoveryStatusSuccess RecoveryStatus = "success" RecoveryStatusPartial RecoveryStatus = "partial" RecoveryStatusFailed RecoveryStatus = "failed" )
type ReplicationConfig ¶
type ReplicationConfig struct {
Mode ReplicationMode
SecondaryPath string
SyncInterval time.Duration
// contains filtered or unexported fields
}
ReplicationConfig defines replication settings
type ReplicationMode ¶
type ReplicationMode string
ReplicationMode defines how replication works
const ( ReplicationModeAsync ReplicationMode = "async" ReplicationModeSync ReplicationMode = "sync" )
type SSDCache ¶
type SSDCache struct {
// contains filtered or unexported fields
}
SSDCache implements a tiered cache with memory and SSD storage
func NewSSDCache ¶
NewSSDCache creates a new SSD-backed cache
func NewSSDCacheWithReplication ¶
func NewSSDCacheWithReplication(memSize, ssdSize int64, primaryPath string, config *ReplicationConfig) (*SSDCache, error)
NewSSDCacheWithReplication creates a cache with replication
func RecoverFromDisaster ¶
RecoverFromDisaster creates a new cache from backup
func (*SSDCache) ApplyDemotionPolicy ¶
func (c *SSDCache) ApplyDemotionPolicy()
ApplyDemotionPolicy actively demotes old items based on policy
func (*SSDCache) CheckIntegrity ¶
func (c *SSDCache) CheckIntegrity() (*IntegrityReport, error)
CheckIntegrity verifies cache data integrity
func (*SSDCache) CleanOrphanedFiles ¶
func (c *SSDCache) CleanOrphanedFiles() (*IntegrityReport, error)
CleanOrphanedFiles removes files without index entries
func (*SSDCache) CreateBackup ¶
func (c *SSDCache) CreateBackup(backupDir string, backupType BackupType) (*BackupInfo, error)
CreateBackup creates a full backup of the cache
func (*SSDCache) CreateEncryptedBackup ¶
func (c *SSDCache) CreateEncryptedBackup(backupDir string, backupType BackupType, encryptionKey []byte) (*BackupInfo, error)
CreateEncryptedBackup creates an encrypted backup
func (*SSDCache) CreateIncrementalBackup ¶
func (c *SSDCache) CreateIncrementalBackup(backupDir string, baseBackupID string) (*BackupInfo, error)
CreateIncrementalBackup creates an incremental backup since the last full backup
func (*SSDCache) EnableCompression ¶
EnableCompression turns on data compression for SSD storage
func (*SSDCache) EnableDeduplication ¶
func (c *SSDCache) EnableDeduplication()
EnableDeduplication turns on content deduplication
func (*SSDCache) EnableEncryption ¶
EnableEncryption enables AES-256-GCM encryption for data at rest
func (*SSDCache) EnableMonitoring ¶
func (c *SSDCache) EnableMonitoring()
EnableMonitoring turns on performance tracking
func (*SSDCache) ExportToJSON ¶
ExportToJSON exports cache contents to JSON
func (*SSDCache) GetCompressionStats ¶
func (c *SSDCache) GetCompressionStats() *CompressionStats
GetCompressionStats returns compression statistics
func (*SSDCache) GetDeduplicationStats ¶
func (c *SSDCache) GetDeduplicationStats() *DeduplicationStats
GetDeduplicationStats returns deduplication statistics
func (*SSDCache) GetFailoverStatus ¶
func (c *SSDCache) GetFailoverStatus() FailoverStatus
GetFailoverStatus returns current failover status
func (*SSDCache) GetLastRecoveryReport ¶
func (c *SSDCache) GetLastRecoveryReport() *RecoveryReport
GetLastRecoveryReport returns the last recovery report
func (*SSDCache) GetMemoryKeys ¶
GetMemoryKeys returns keys currently in memory (for testing)
func (*SSDCache) GetPerformanceMetrics ¶
func (c *SSDCache) GetPerformanceMetrics() *PerformanceMetrics
GetPerformanceMetrics returns current performance stats
func (*SSDCache) GetShardForKey ¶
GetShardForKey returns the shard number for a given key
func (*SSDCache) GetWriteStats ¶
GetWriteStats returns wear leveling statistics
func (*SSDCache) ImportFromJSON ¶
ImportFromJSON imports cache contents from JSON
func (*SSDCache) IsUsingSecondary ¶
IsUsingSecondary returns true if using secondary cache
func (*SSDCache) RecoverIndex ¶
RecoverIndex rebuilds the index from disk files
func (*SSDCache) RepairCorruption ¶
func (c *SSDCache) RepairCorruption(report *IntegrityReport) (int, error)
RepairCorruption attempts to fix corrupted entries
func (*SSDCache) RestoreFromBackup ¶
RestoreFromBackup restores cache from a backup
func (*SSDCache) RotateEncryptionKey ¶
RotateEncryptionKey changes the encryption key for new data
func (*SSDCache) SetDemotionPolicy ¶
func (c *SSDCache) SetDemotionPolicy(policy *DemotionPolicy)
SetDemotionPolicy configures when data moves from memory to SSD
func (*SSDCache) SetPromotionPolicy ¶
func (c *SSDCache) SetPromotionPolicy(policy *PromotionPolicy)
SetPromotionPolicy configures when data moves from SSD to memory
func (*SSDCache) SimulateFailure ¶
func (c *SSDCache) SimulateFailure()
SimulateFailure simulates a primary cache failure for testing
func (*SSDCache) StartBackupScheduler ¶
func (c *SSDCache) StartBackupScheduler(schedule *BackupSchedule) error
StartBackupScheduler starts automatic backups
func (*SSDCache) StopBackupScheduler ¶
func (c *SSDCache) StopBackupScheduler()
StopBackupScheduler stops automatic backups
type SequentialPrefetchStrategy ¶
type SequentialPrefetchStrategy struct {
// contains filtered or unexported fields
}
SequentialPrefetchStrategy prefetches sequential keys
func (*SequentialPrefetchStrategy) GetPrefetchKeys ¶
func (s *SequentialPrefetchStrategy) GetPrefetchKeys(key string) []string
func (*SequentialPrefetchStrategy) ShouldPrefetch ¶
func (s *SequentialPrefetchStrategy) ShouldPrefetch(key string, pattern *AccessPatternAnalysis) bool
type SizedCacheItem ¶
SizedCacheItem includes size tracking
type SizedCacheStats ¶
type SizedCacheStats struct {
CacheStats
CurrentBytes int64
MaxBytes int64
BytesEvicted int64
}
SizedCacheStats includes byte size information
func (*SizedCacheStats) MemoryUsage ¶
func (s *SizedCacheStats) MemoryUsage() float64
MemoryUsage returns current memory usage percentage
type SizedLRU ¶
type SizedLRU struct {
// contains filtered or unexported fields
}
SizedLRU implements an LRU cache with byte size limits
func NewSizedLRU ¶
NewSizedLRU creates a cache with byte size limit
func (*SizedLRU) Put ¶
func (c *SizedLRU) Put(ctx context.Context, container, artifact string, reader io.Reader, size int64) error
Put adds an item to the cache with size tracking
func (*SizedLRU) Stats ¶
func (c *SizedLRU) Stats() *SizedCacheStats
Stats returns current cache statistics
type StorageTier ¶
type StorageTier struct {
Name string
CostPerGB float64 // $ per GB per month
AccessCost float64 // $ per 1000 requests
Latency time.Duration
Capacity int64
CurrentUsage int64
}
StorageTier represents different storage cost tiers
type TieredCache ¶
type TieredCache struct {
// contains filtered or unexported fields
}
func NewTieredCache ¶
func NewTieredCache(config *Config, logger *zap.Logger) *TieredCache
func (*TieredCache) Delete ¶
func (tc *TieredCache) Delete(key string) error
func (*TieredCache) Flush ¶
func (tc *TieredCache) Flush()
func (*TieredCache) GetMetrics ¶
func (tc *TieredCache) GetMetrics() map[string]interface{}
func (*TieredCache) HealthCheck ¶
func (tc *TieredCache) HealthCheck() error
type TimeBasedStrategy ¶
type TimeBasedStrategy struct {
// contains filtered or unexported fields
}
TimeBasedStrategy handles time-aware caching decisions
func NewTimeBasedStrategy ¶
func NewTimeBasedStrategy() *TimeBasedStrategy
NewTimeBasedStrategy creates a time-aware strategy
func (*TimeBasedStrategy) GetOptimalTTL ¶
GetOptimalTTL returns TTL based on time of day
func (*TimeBasedStrategy) RecordHourlyPattern ¶
func (t *TimeBasedStrategy) RecordHourlyPattern(requests int, cacheSize int64, hotKeys []string)
RecordHourlyPattern records usage for the current hour
type UserAwareCacheManager ¶
type UserAwareCacheManager struct {
// contains filtered or unexported fields
}
UserAwareCacheManager manages user-specific caching
func NewUserAwareCacheManager ¶
func NewUserAwareCacheManager(cache *SSDCache, maxPerUser int64) *UserAwareCacheManager
NewUserAwareCacheManager creates a user-aware cache manager
func (*UserAwareCacheManager) GetUserProfile ¶
func (u *UserAwareCacheManager) GetUserProfile(userID string) *UserCacheProfile
GetUserProfile returns or creates a user's cache profile
func (*UserAwareCacheManager) ShouldCacheForUser ¶
func (u *UserAwareCacheManager) ShouldCacheForUser(userID string, size int64) bool
ShouldCacheForUser determines if data should be cached for this user
func (*UserAwareCacheManager) TrackUserAccess ¶
func (u *UserAwareCacheManager) TrackUserAccess(userID, key string, size int64)
TrackUserAccess records a user's data access
type UserCacheProfile ¶
type UserCacheProfile struct {
UserID string
HotKeys []string
AvgObjectSize int64
TotalSize int64 // Track total size for proper averaging
AccessCount int64 // Track access count for proper averaging
AccessFrequency float64
LastAccess time.Time
CacheQuota int64 // Bytes allocated to this user
CurrentUsage int64
}
UserCacheProfile tracks per-user cache behavior