Documentation
¶
Index ¶
- type CacheEntry
- type CacheMetrics
- type GlobalCache
- func (gc *GlobalCache) Clear()
- func (gc *GlobalCache) Close()
- func (gc *GlobalCache) Delete(key string) bool
- func (gc *GlobalCache) Get(key string) (interface{}, bool)
- func (gc *GlobalCache) GetMetrics() CacheMetrics
- func (gc *GlobalCache) GetWithAge(key string) (interface{}, bool, time.Duration)
- func (gc *GlobalCache) HitRate() float64
- func (gc *GlobalCache) Set(key string, value interface{}, ttl ...time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheEntry ¶
type CacheEntry struct {
Key string `json:"key"`
Value interface{} `json:"value"`
Expiration time.Time `json:"expiration"`
Created time.Time `json:"created"`
LastAccess time.Time `json:"last_access"`
HitCount int64 `json:"hit_count"`
Size int64 `json:"size"`
}
CacheEntry represents a single cache entry
type CacheMetrics ¶
type CacheMetrics struct {
Hits int64
Misses int64
Sets int64
Deletes int64
Evictions int64
TotalSize int64
ItemCount int
// contains filtered or unexported fields
}
CacheMetrics tracks cache performance
type GlobalCache ¶
type GlobalCache struct {
// contains filtered or unexported fields
}
GlobalCache provides thread-safe caching with TTL and persistence
func NewGlobalCache ¶
func NewGlobalCache(maxSize int64, defaultTTL time.Duration, persistPath string) *GlobalCache
NewGlobalCache creates a new global cache instance
func (*GlobalCache) Close ¶
func (gc *GlobalCache) Close()
Close stops the cleanup goroutine and saves cache to disk
func (*GlobalCache) Delete ¶
func (gc *GlobalCache) Delete(key string) bool
Delete removes an item from the cache
func (*GlobalCache) Get ¶
func (gc *GlobalCache) Get(key string) (interface{}, bool)
Get retrieves a value from the cache
func (*GlobalCache) GetMetrics ¶
func (gc *GlobalCache) GetMetrics() CacheMetrics
GetMetrics returns cache metrics
func (*GlobalCache) GetWithAge ¶
func (gc *GlobalCache) GetWithAge(key string) (interface{}, bool, time.Duration)
GetWithAge returns a value and its age
func (*GlobalCache) HitRate ¶
func (gc *GlobalCache) HitRate() float64
HitRate returns the cache hit rate
Click to show internal directories.
Click to hide internal directories.