Files
main.tsmain
What you'll learn
- Register CacheModule with a default ttl and explain what is stored and where
- Cache a GET route with CacheInterceptor, choose its key with @CacheKey, and invalidate it on a write
- Cache by hand with CACHE_MANAGER: get, set with a ttl, del and clear
Press Run tests to start the app. Its log appears here.Graded endpoints
A cat for the statistics
Computed once and stored by the interceptor under cats-stats
Served from the cache: the same response, and computed is still 1
A write: the handler drops the cached statistics
Recomputed, because the entry was invalidated under the key the interceptor uses
A miss: computed and stored under facts:1
A hit: the stored value, computed still 1
Everything forgotten
A miss again: computed twice now
The interceptor's entry went with the rest