http-cache icon indicating copy to clipboard operation
http-cache copied to clipboard

What is the eviction logic?

Open gzp79 opened this issue 2 months ago • 1 comments

My data to cache are immutable, "cache forever", but i would not like to keep everything "forever" and i'd like to give some size limit on the cache (with lru policy if possible). I found no info on this, neither in this project or the mentioned cacache crate. Could you please provide some info if it is possible.

gzp79 avatar Oct 13 '25 16:10 gzp79

I don't have logic for eviction by size but the 1.0 alphas have this available: https://github.com/06chaynes/http-cache/blob/main/http-cache/src/lib.rs#L104 so the entries could be removed based on age. Ideally, at least from my perspective, functionality like what you described would be part of the underlying cache manager and not this library. For cacache specifically there is this issue asking about eviction but doesn't seem like there's a ton of interest in adding this in https://github.com/zkat/cacache-rs/issues/28

That said it may be possible to add in the logic on your end by interfacing with the cache directly and using the Metadata cacache provides to implement the eviction logic as size is one of the data points.

06chaynes avatar Oct 14 '25 01:10 06chaynes