jellydator / ttlcache

An in-memory cache with item expiration and generics
MIT License
883 stars 115 forks source link

Question: about memory exceeding the limit #110

Closed BaiZe1998 closed 9 months ago

BaiZe1998 commented 10 months ago

desc:If a large object remains in memory after a set, does it cause the set memory limit to be exceeded all the time. Is it better to eliminate it by for loop?

https://github.com/jellydator/ttlcache/blob/v3/cache.go#L148

if c.options.capacity != 0 && uint64(len(c.items.values)) >= c.options.capacity {
    // delete the oldest item
    c.evict(EvictionReasonCapacityReached, c.items.lru.Back())
}
swithek commented 10 months ago

Can you explain what you're trying to achieve? An example would help too.