angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

Cache separate by different parameter values #42

Closed muratcorlu closed 5 years ago

muratcorlu commented 5 years ago

Is it possible to keep caches for old function parameters too?

@Cacheable()
getArticle(id: string): Observable<Article> {
  ....
}

I call this method several times with different articleIds in a view, then none of my requests are being cached actually. My expected behaviour was to cached every article request separately.

angelnikolov commented 5 years ago

You can provide a maxCacheCount parameter to the Cacheable like:

@Cacheable({
   maxCacheCount: 100
})

This will make the decorator cache the last 100 calls.

muratcorlu commented 5 years ago

OK, I think this'll fulfil my needs. Thanks.