# SharedResponseCache

Keeps responses by key (normally the URL) for their `max-age`, and shares
a request already in flight, so several layers over one feed (alerts split
by type) cost one request.

This is a class exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import { SharedResponseCache } from "@mapcairn/core";
 
class SharedResponseCache<T>
```

## Type parameters

- `T`

## Constructors

### (constructor)

```ts
constructor(options: SharedResponseCacheOptions);
```

Constructs a new instance of the `SharedResponseCache` class

- `options` (`SharedResponseCacheOptions`)

## Methods

### load

```ts
load(key: string, start: (signal: AbortSignal) => Promise<CachedResponse<T>>, signal?: AbortSignal): Promise<T>;
```

Returns the fresh value for `key`, joins a request in flight, or calls
`start` with a signal the cache controls.

- `key` (`string`)
- `start` (`(signal: AbortSignal) => Promise<CachedResponse<T>>`)
- `signal?` (`AbortSignal`)

## Remarks

Each caller may pass its own signal. A caller that gives up is
 rejected with `LayerError` `aborted` at once, but the request carries on
 for the others; only when every caller has given up is it cancelled.
 Failures are passed to every waiting caller and never kept.

## See also

- [`SharedResponseCacheOptions`](https://docs.mapcairn.com/api/core/SharedResponseCacheOptions.md)
- [`CachedResponse`](https://docs.mapcairn.com/api/core/CachedResponse.md)

Source: [packages/core/src/layers/responseCache.ts:62](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/layers/responseCache.ts#L62)
