typesense / typesense-dart

Dart client for Typesense
https://typesense.org/docs
Apache License 2.0
73 stars 16 forks source link

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

Open happy-san opened 3 years ago

happy-san commented 3 years ago

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 commented 3 years ago

Assigned to @harisarang

happy-san commented 3 years ago

@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.

CoryADavis commented 2 years ago

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

happy-san commented 2 years ago

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

CoryADavis commented 2 years ago

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

Thank you!

o-artebiakin commented 9 months ago

@happy-san can we trigger cache clear manually?

happy-san commented 9 months ago

@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?