Foundatio icon indicating copy to clipboard operation
Foundatio copied to clipboard

InMemoryCacheClient Maximum Size

Open Terebi42 opened this issue 4 years ago • 5 comments
trafficstars

In addition to being able to limit the total number of items, it would be nice to be able to limit the size, so that items could be removed due to memory pressure.

Terebi42 avatar Aug 25 '21 21:08 Terebi42

I'm not sure how you would efficiently get the objects size without a big hit to performance. Have you played around with this any? Typically we know the objects going into cache and can reason about size / maximum items we want to persist.

niemyjski avatar Aug 26 '21 02:08 niemyjski

Well, you serialize everything you are putting into the cache aren't you? Wouldn't that let you know the size?

Terebi42 avatar Aug 26 '21 19:08 Terebi42

@Terebi42 for the in memory cache, it's an option on whether or not you want to serialize things when adding them to the cache.

ejsmith avatar Aug 26 '21 19:08 ejsmith

Well, then maybe the maximum size feature would only work when serialization is on?

Terebi42 avatar Aug 26 '21 19:08 Terebi42

Yeah, that's a possibility. Would you want to submit a PR for this feature?

ejsmith avatar Aug 26 '21 19:08 ejsmith