@@ -107,11 +107,14 @@ export const cacheMiddleware = ({ type, storage }: CacheOptions) => {
107107 } )
108108
109109
110+ const { localCacheOptions } = ctx . config
111+
110112 const cacheReadSpan = createCacheSpan ( cacheType , 'read' , tracer , span )
111113 let cached : void | Cached
112114 try {
113- const cacheHasWithSegment = await storage . has ( keyWithSegment )
114- cached = cacheHasWithSegment ? await storage . get ( keyWithSegment ) : await storage . get ( key )
115+ const cacheHasWithSegment = await storage . has ( keyWithSegment , localCacheOptions )
116+ const keyToUse = cacheHasWithSegment ? keyWithSegment : key
117+ cached = await storage . get ( keyToUse , undefined , localCacheOptions )
115118 } catch ( error ) {
116119 ErrorReport . create ( { originalError : error } ) . injectOnSpan ( cacheReadSpan )
117120 logger ?. warn ( { message : 'Error reading from the HttpClient cache' , error } )
@@ -223,13 +226,18 @@ export const cacheMiddleware = ({ type, storage }: CacheOptions) => {
223226
224227 const cacheWriteSpan = createCacheSpan ( cacheType , 'write' , tracer , span )
225228 try {
226- await storage . set ( setKey , {
227- etag,
228- expiration,
229- response : { data : cacheableData , headers, status} ,
230- responseEncoding,
231- responseType,
232- } )
229+ await storage . set (
230+ setKey ,
231+ {
232+ etag,
233+ expiration,
234+ response : { data : cacheableData , headers, status} ,
235+ responseEncoding,
236+ responseType,
237+ } ,
238+ undefined ,
239+ localCacheOptions
240+ )
233241
234242 span ?. log ( {
235243 event : HttpLogEvents . LOCAL_CACHE_SAVED ,
0 commit comments