Cache represents a thread-safe in-memory cache with TTL and LRU eviction policies
| 20 | |
| 21 | // Cache represents a thread-safe in-memory cache with TTL and LRU eviction policies |
| 22 | type Cache struct { |
| 23 | mu sync.RWMutex |
| 24 | items map[string]*list.Element // Map of keys to list elements |
| 25 | eviction *list.List // Doubly-linked list for eviction |
| 26 | capacity int // Maximum number of items in the cache |
| 27 | } |
| 28 | |
| 29 | // NewCache initializes and returns a new Cache with the given capacity |
| 30 | func NewCache(capacity int) *Cache { |
nothing calls this directly
no outgoing calls
no test coverage detected