File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,10 @@ const datasource = new (class MoviesAPI extends HTTPDataSource {
8484 headers: {
8585 ' X-Foo' : ' bar' ,
8686 },
87+ requestCache: {
88+ maxTtl: 1000 * 60 * 10 , // 10min, will respond for 10min with the cached result (updated every 10min)
89+ maxTtlIfError: 1000 * 60 * 30 , // 30min, will respond in an error case with the cached response (for further 20min)
90+ },
8791 })
8892 }
8993})()
Original file line number Diff line number Diff line change @@ -53,8 +53,8 @@ export interface HTTPDataSourceOptions {
5353
5454function apolloKeyValueCacheToKeyv ( cache : KeyValueCache ) : Store < string > {
5555 return {
56- async get ( key : string ) {
57- return await cache . get ( key )
56+ get ( key : string ) {
57+ return cache . get ( key )
5858 } ,
5959 clear ( ) {
6060 throw new Error ( 'clear() method is not supported by apollo key value cache' )
@@ -67,8 +67,8 @@ function apolloKeyValueCacheToKeyv(cache: KeyValueCache): Store<string> {
6767
6868 return true
6969 } ,
70- async set ( key : string , value : string , ttl ?: number ) {
71- return await cache . set ( key , value , {
70+ set ( key : string , value : string , ttl ?: number ) {
71+ return cache . set ( key , value , {
7272 ttl,
7373 } )
7474 } ,
You can’t perform that action at this time.
0 commit comments