lru icon indicating copy to clipboard operation
lru copied to clipboard

How can I keep the most recently used *unique* items?

Open timwis opened this issue 6 years ago • 0 comments

Hello, I have a use case where I'm querying an API that tells browsers not to cache its responses. As a user bounces around from page to page in my application, the browser makes a fresh request each time, even if you're hitting "back" and "forward" repeatedly. I'd like to use a cache to save the most recent, say, 5 requests. But it should be the most recent unique requests; otherwise if you hit "back" and "forward" repeatedly, your cache will only contain those 2 pages and knock out any others you recently hit.

Is there a way to consider the uniqueness of items in an LRU like this one? Or am I thinking about it all wrong?

Thanks for your time.

timwis avatar Apr 14 '18 20:04 timwis