Closed alindberg closed 6 years ago
@alindberg You don't cache the requests, but you cache methods which return Observables.
So you can create a method which takes the key
as a parameter, and that will be used for caching. Then when you decorate the method with @Cacheable
, you can just add the maxCacheCount
parameter to it to specify how many unique parameters method invocations should be cached. If you decorate your method with something like:
@Cacheable({
maxCacheCount: 2
})
getData(key: string){}
Both your requests will be essentially cached.
I would like to cache the following example:
/service/key?=1
/service/key?=2
Etc. Additional requests to the above keys would returned from cache. Keys not matching would be returned from the HTTPClient with the results being added to the cache.
The data requests could be from either Get or Post.
Thank you for your guidance.