karimsa/rsxjs

Add cache component

Opened this issue · 0 comments

Requirements:

Proactive caching

With this strategy, the component should be placed before the original function and should first try to return from cache before calling the function.

Parameters:

  • Cache size
  • Argument hashing
  • GBC? null for never or a time period

Caching as a Fallback:

In this strategy, caching would need to appear both before the function and after the function in order to create the cache and then use it on failure.

export default flow(
  Cache.fromAsync.factory({
    strategy: Cache.STRAT_PROACTIVE,
    size: 2,
  }),
)( fn )