Documentation
¶
Index ¶
- type BatchLoadOptions
- type Cache
- func (c *Cache) Clear()
- func (c *Cache) Close() error
- func (c *Cache) EvictOldEntries()
- func (c *Cache) GetHotCacheAge() time.Duration
- func (c *Cache) GetSecurityInfo() map[string]interface{}
- func (c *Cache) GetStats() *CacheStats
- func (c *Cache) IsHotCacheValid() bool
- func (c *Cache) LoadHotCache() error
- func (c *Cache) LoadHotCacheWithOptions(opts *HotCacheLoadOptions) error
- func (c *Cache) RefreshIfNeeded() error
- func (c *Cache) Search(query string, opts *BatchLoadOptions) (*SearchResult, error)
- func (c *Cache) SetEvictionPolicy(policy EvictionPolicy)
- func (c *Cache) SetMaxCacheAge(maxAge time.Duration)
- func (c *Cache) SetSecurityLevel(level int)
- func (c *Cache) StartBackgroundRefresh()
- func (c *Cache) StartCacheMaintenance()
- func (c *Cache) StopBackgroundRefresh()
- func (c *Cache) StopCacheMaintenance()
- func (c *Cache) WarmUpCache() error
- type CacheEntry
- type CacheStats
- type EvictionPolicy
- type HotCacheLoadOptions
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchLoadOptions ¶
type BatchLoadOptions struct {
MaxBatches int
MaxResults int
SkipHotCache bool
QueryFilter *securestorage.QueryOptions
BatchSize int // Override default batch size
ParallelLoad bool // Enable parallel batch loading
CacheBatches bool // Cache loaded batches temporarily
RetryAttempts int // Number of retry attempts for failed batches
}
BatchLoadOptions controls batch loading behavior
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides a hybrid memory cache for command records with hot cache and batch loading
func NewCache ¶
func NewCache(cfg *config.CacheConfig, storage *securestorage.SecureStorage) *Cache
NewCache creates a new hybrid memory cache instance
func (*Cache) EvictOldEntries ¶
func (c *Cache) EvictOldEntries()
EvictOldEntries removes entries based on the configured eviction policy
func (*Cache) GetHotCacheAge ¶
GetHotCacheAge returns how long since the hot cache was last refreshed
func (*Cache) GetSecurityInfo ¶
GetSecurityInfo returns information about secure memory handling
func (*Cache) GetStats ¶
func (c *Cache) GetStats() *CacheStats
GetStats returns cache performance statistics
func (*Cache) IsHotCacheValid ¶
IsHotCacheValid checks if the hot cache is still valid
func (*Cache) LoadHotCache ¶
LoadHotCache loads the most recent commands into the hot cache
func (*Cache) LoadHotCacheWithOptions ¶
func (c *Cache) LoadHotCacheWithOptions(opts *HotCacheLoadOptions) error
LoadHotCacheWithOptions loads the hot cache with specific options
func (*Cache) RefreshIfNeeded ¶
RefreshIfNeeded refreshes the hot cache if the refresh interval has passed
func (*Cache) Search ¶
func (c *Cache) Search(query string, opts *BatchLoadOptions) (*SearchResult, error)
Search performs a search operation using hot cache and batch loading
func (*Cache) SetEvictionPolicy ¶
func (c *Cache) SetEvictionPolicy(policy EvictionPolicy)
SetEvictionPolicy changes the cache eviction policy
func (*Cache) SetMaxCacheAge ¶
SetMaxCacheAge sets the maximum age for cache entries
func (*Cache) SetSecurityLevel ¶
SetSecurityLevel configures the memory security level
func (*Cache) StartBackgroundRefresh ¶
func (c *Cache) StartBackgroundRefresh()
StartBackgroundRefresh starts automatic cache refresh
func (*Cache) StartCacheMaintenance ¶
func (c *Cache) StartCacheMaintenance()
StartCacheMaintenance starts automatic cache maintenance
func (*Cache) StopBackgroundRefresh ¶
func (c *Cache) StopBackgroundRefresh()
StopBackgroundRefresh stops automatic cache refresh
func (*Cache) StopCacheMaintenance ¶
func (c *Cache) StopCacheMaintenance()
StopCacheMaintenance stops automatic cache maintenance
func (*Cache) WarmUpCache ¶
WarmUpCache preloads the cache for better performance
type CacheEntry ¶
type CacheEntry struct {
Record *storage.CommandRecord
AccessTime time.Time
AccessCount int64
InsertTime time.Time
Size int64
}
CacheEntry wraps a command record with metadata for eviction policies
type CacheStats ¶
type CacheStats struct {
HotCacheSize int `json:"hot_cache_size"`
CurrentMemoryMB int64 `json:"current_memory_mb"`
CacheHits int64 `json:"cache_hits"`
CacheMisses int64 `json:"cache_misses"`
BatchesLoaded int64 `json:"batches_loaded"`
LastRefresh time.Time `json:"last_refresh"`
RefreshInterval time.Duration `json:"refresh_interval"`
HitRatio float64 `json:"hit_ratio"`
}
CacheStats provides cache performance statistics
type EvictionPolicy ¶
type EvictionPolicy int
EvictionPolicy defines the cache eviction strategy
const ( EvictionLRU EvictionPolicy = iota // Least Recently Used EvictionLFU // Least Frequently Used EvictionTTL // Time To Live based EvictionSize // Size based (oldest entries) )
type HotCacheLoadOptions ¶
type HotCacheLoadOptions struct {
Size int `json:"size"`
ForceRefresh bool `json:"force_refresh"`
SessionFilter string `json:"session_filter"`
HostnameFilter string `json:"hostname_filter"`
SinceTime *time.Time `json:"since_time"`
}
HotCacheLoadOptions provides options for loading the hot cache
type SearchResult ¶
type SearchResult struct {
Records []*storage.CommandRecord `json:"records"`
TotalMatches int `json:"total_matches"`
FromCache int `json:"from_cache"`
FromBatches int `json:"from_batches"`
SearchTime time.Duration `json:"search_time"`
}
SearchResult contains search results with metadata