File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
88## [ Unreleased]
99
10+ ### Added
11+
12+ - Clarification about ` LRUCache ` usage
13+
1014## [ 0.2.21] - 2023-02-24
1115
1216### Fixed
Original file line number Diff line number Diff line change @@ -19,4 +19,14 @@ export default class Status extends ExternalClient {
1919 metric : 'status-get-raw' ,
2020 } )
2121 }
22+
23+ public async getStatusAndForceMaxAge (
24+ status : number
25+ ) : Promise < IOResponse < string > > {
26+ return this . http . get ( status . toString ( ) , {
27+ // when using an LRUCache, this will force the response to be cached
28+ forceMaxAge : 5000 ,
29+ metric : 'status-get-forceMaxAge' ,
30+ } )
31+ }
2232}
Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ import { validate } from './middlewares/validate'
88const TIMEOUT_MS = 800
99
1010// Create a LRU memory cache for the Status client.
11+ // The 'max' parameter sets the size of the cache.
1112// The @vtex /api HttpClient respects Cache-Control headers and uses the provided cache.
13+ // Note that the response from the API being called must include an 'etag' header
14+ // or a 'cache-control' header with a 'max-age' value. If neither exist, the response will not be cached.
15+ // To force responses to be cached, consider adding the `forceMaxAge` option to your client methods.
1216const memoryCache = new LRUCache < string , any > ( { max : 5000 } )
1317
1418metrics . trackCache ( 'status' , memoryCache )
You can’t perform that action at this time.
0 commit comments