Skip to content

Commit

Permalink
lib: more cache fixes
Browse files Browse the repository at this point in the history
Closes nodejs#3806

Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
  • Loading branch information
flakey5 committed Nov 8, 2024
1 parent fe1f132 commit 7eacbe5
Show file tree
Hide file tree
Showing 11 changed files with 364 additions and 435 deletions.
28 changes: 5 additions & 23 deletions docs/docs/api/CacheStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The store must implement the following functions:

### Getter: `isFull`

This tells the cache interceptor if the store is full or not. If this is true,
Optional. This tells the cache interceptor if the store is full or not. If this is true,
the cache interceptor will not attempt to cache the response.

### Function: `createReadStream`
Expand All @@ -30,18 +30,18 @@ Parameters:

* **req** `Dispatcher.RequestOptions` - Incoming request

Returns: `CacheStoreReadable | Promise<CacheStoreReadable | undefined> | undefined` - If the request is cached, a readable for the body is returned. Otherwise, `undefined` is returned.
Returns: `Readable | Promise<Readable | undefined> | undefined` - If the request is cached, a readable for the body is returned. Otherwise, `undefined` is returned.

### Function: `createWriteStream`

Parameters:

* **req** `Dispatcher.RequestOptions` - Incoming request
* **value** `CacheStoreValue` - Response to store
* **value** `CachedResponse` - Response to store

Returns: `CacheStoreWriteable | undefined` - If the store is full, return `undefined`. Otherwise, return a writable so that the cache interceptor can stream the body and trailers to the store.
Returns: `Writable | undefined` - If the store is full, return `undefined`. Otherwise, return a writable so that the cache interceptor can stream the body and trailers to the store.

## `CacheStoreValue`
## `CachedResponse`

This is an interface containing the majority of a response's data (minus the body).

Expand All @@ -57,10 +57,6 @@ This is an interface containing the majority of a response's data (minus the bod

`(Buffer | Buffer[])[]` - The response's headers.

### Property `rawTrailers`

`string[] | undefined` - The response's trailers.

### Property `vary`

`Record<string, string> | undefined` - The headers defined by the response's `Vary` header
Expand Down Expand Up @@ -96,20 +92,6 @@ is either the same sa staleAt or the `max-stale` caching directive.

The store must not return a response after the time defined in this property.

## `CacheStoreReadable`

This extends Node's [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable)
and defines extra properties relevant to the cache interceptor.

### Getter: `value`

The response's [`CacheStoreValue`](#cachestorevalue)

## `CacheStoreWriteable`

This extends Node's [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable)
and defines extra properties relevant to the cache interceptor.

### Setter: `rawTrailers`

If the response has trailers, the cache interceptor will pass them to the cache
Expand Down
Loading

0 comments on commit 7eacbe5

Please sign in to comment.