Documentation
¶
Overview ¶
Package cache provides a lock-free adaptive in-memory LRU cache implementation. CloxCache combines CLOCK-Pro eviction with TinyLFU admission and adaptive frequency decay.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeShardConfig ¶
ComputeShardConfig calculates optimal shard configuration for a target cache size
func FormatMemory ¶
FormatMemory formats bytes as human-readable string
Types ¶
type CloxCache ¶
type CloxCache[T any] struct { // contains filtered or unexported fields }
CloxCache is a lock-free adaptive in-memory cache with CLOCK-Pro eviction. It stores generic values of type T.
func NewCloxCache ¶
NewCloxCache creates a new cache with the given configuration
type Config ¶
Config holds CloxCache configuration
func ConfigFromHardware ¶
func ConfigFromHardware() Config
ConfigFromHardware creates a CloxCache config from detected hardware
func ConfigFromMemorySize ¶
ConfigFromMemorySize creates a CloxCache config for a specific memory target
func (Config) EstimateMemoryUsage ¶
EstimateMemoryUsage estimates total memory usage for a given configuration
type HardwareConfig ¶
type HardwareConfig struct {
NumCPU int // Number of logical CPUs
TotalMemory uint64 // Total system memory in bytes
CacheSize uint64 // Recommended cache size in bytes
NumShards int // Recommended number of shards
SlotsPerShard int // Recommended slots per shard
}
HardwareConfig contains detected hardware specifications
func DetectHardware ¶
func DetectHardware() HardwareConfig
DetectHardware detects system hardware and returns recommended configuration