@@ -107,11 +107,14 @@ export const cacheMiddleware = ({ type, storage }: CacheOptions) => {
107
107
} )
108
108
109
109
110
+ const { localCacheOptions } = ctx . config
111
+
110
112
const cacheReadSpan = createCacheSpan ( cacheType , 'read' , tracer , span )
111
113
let cached : void | Cached
112
114
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 )
115
118
} catch ( error ) {
116
119
ErrorReport . create ( { originalError : error } ) . injectOnSpan ( cacheReadSpan )
117
120
logger ?. warn ( { message : 'Error reading from the HttpClient cache' , error } )
@@ -223,13 +226,18 @@ export const cacheMiddleware = ({ type, storage }: CacheOptions) => {
223
226
224
227
const cacheWriteSpan = createCacheSpan ( cacheType , 'write' , tracer , span )
225
228
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
+ )
233
241
234
242
span ?. log ( {
235
243
event : HttpLogEvents . LOCAL_CACHE_SAVED ,
0 commit comments