Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRUCache provides a simple LRU cache with both size and TTL limits. It uses RWMutex for optimal concurrent access patterns - multiple concurrent reads are allowed while writes get exclusive access.
func NewLRUCache ¶
NewLRUCache creates a new LRU cache with the specified maximum size and TTL.
func (*LRUCache) Add ¶
Add marks a key as cached. This operation uses a write lock for exclusive access. If the key already exists, its expiration time is updated and it's moved to the end of the LRU order. If the cache exceeds maxSize, oldest entries are evicted.
Click to show internal directories.
Click to hide internal directories.