typesense-dart icon indicating copy to clipboard operation
typesense-dart copied to clipboard

Implement `Least Recently Used` eviction in `RequestCache` .

Open happy-san opened this issue 4 years ago • 7 comments

Is your feature request related to a problem? Please describe.

_cachedResponses doesn't have a limit on the number of _Cache's it can store and the expired _Cache is conditionally deleted, so a memory leak occurs.

Describe the solution you'd like

Implement an LRU algorithm.

Additional context

related issue

happy-san avatar Jul 30 '21 21:07 happy-san

Assigned to @harisarang

happy-san avatar Aug 14 '21 15:08 happy-san

@harisarang Maybe read up about TLRU- Time aware LRU scheme. I think TLRU scheme would be more relevant because LRU doesn't take Time to utilize (TLU) of the cached data into consideration.

Otherwise, for now, using the dcache package in cache function is fine.

happy-san avatar Aug 14 '21 15:08 happy-san

Is this library considered safe for production use without this fix?

CoryADavis avatar Mar 28 '22 06:03 CoryADavis

@CoryADavis I wouldn't recommend setting cachedSearchResultsTTL in production code yet.

happy-san avatar Mar 29 '22 02:03 happy-san

Ahh, understood, this issue is only related to a feature that is off by default.

Thank you!

CoryADavis avatar Mar 29 '22 03:03 CoryADavis

@happy-san can we trigger cache clear manually?

o-artebiakin avatar Feb 09 '24 12:02 o-artebiakin

@o-artebiakin No, there's no way to clear the cache manually at the moment. Are you planning to use this feature in your app?

happy-san avatar Feb 10 '24 03:02 happy-san