CacheLRU

CacheLRU contains maximum size items Eviction policy: 1. evict TTL-ed entry (if TTL) 2. if oldest entry not expired - evict oldes accessed (LRU)

User can be informed about evicted entries via cache event list.

class CacheLRU : Cache!(K, V)(
K
V
Allocator = Mallocator
) {}

Examples

1 auto lru = new CacheLRU!(int, string);
2 lru.size = 2048; // keep 2048 elements in cache
3 lru.ttl = 60;    // set 60 seconds TTL for items in cache
4 
5 lru.put(1, "one");
6 auto v = lru.get(0);
7 assert(v.isNull);   // no such item in cache
8 v = lru.get(1);
9 assert(v == "one"); // 1 is in cache

Meta