vlio20 / utils-decorators

Decorators for web and node applications
https://vlio20.github.io/utils-decorators/
MIT License
216 stars 13 forks source link

Hot cache #153

Open vlio20 opened 1 year ago

vlio20 commented 1 year ago

@tripodsgames: I want to implement a hot cache functionality into the memoizeAsyncify, i want your opinion on this implementation. WORK IN PROGRESS.

Details: Hot cache system always keeps the cache available When the cache expires the function linked to it is called automatically, during this call the old cache is served until the new value is received. That way, only on the first call or in case of failures the memoizeAsyncify would have some delay

vlio20 commented 1 year ago

@tripodsgames , as I see it hot cache and a cache with TTL shouldn't work together. What do you think of creating a hot cache that can later be provided as an argument to the decorator?

tripodsgames commented 1 year ago

Hi, sorry for not replying sooner, I actually wanted to implement a cache that expires, but continues to serve expired data while fetching new data in the background. I think a better name would be "prefetch" or a combination of two properties like "prefetch" + "lazy" instead of "hot cache"

vlio20 commented 1 year ago

I think that I understand the purpose. Please notice that your PR is currently failing.