* Fetch the complete state of a cached resource, or return null if it's not found.
(url: string)
| 256 | * Fetch the complete state of a cached resource, or return null if it's not found. |
| 257 | */ |
| 258 | async fetchFromCacheOnly(url: string): Promise<CacheState | null> { |
| 259 | const cache = await this.cache; |
| 260 | const metaTable = await this.metadata; |
| 261 | |
| 262 | // Lookup the response in the cache. |
| 263 | const request = this.adapter.newRequest(url); |
| 264 | const response = await cache.match(request, this.config.cacheQueryOptions); |
| 265 | if (response === undefined) { |
| 266 | // It's not found, return null. |
| 267 | return null; |
| 268 | } |
| 269 | |
| 270 | // Next, lookup the cached metadata. |
| 271 | let metadata: UrlMetadata | undefined = undefined; |
| 272 | try { |
| 273 | metadata = await metaTable.read<UrlMetadata>(request.url); |
| 274 | } catch { |
| 275 | // Do nothing, not found. This shouldn't happen, but it can be handled. |
| 276 | } |
| 277 | |
| 278 | // Return both the response and any available metadata. |
| 279 | return {response, metadata}; |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Lookup all resources currently stored in the cache which have no associated hash. |
nothing calls this directly
no test coverage detected
searching dependent graphs…