-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add request deduplication and caching in client #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
6aa83bd
a9ae233
023f834
4d8aecf
47440c0
e914689
9c8636c
309053e
ecc05df
b1fb5e8
1acaab8
821efa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,20 @@ | |
* await libp2p.peerRouting.findPeer(peerIdFromString('QmFoo')) | ||
* ``` | ||
* | ||
* ### Caching | ||
* | ||
* By default, the client caches responses in browser environments for a duration of 5 minutes. | ||
|
||
* | ||
* If caching is enabled, the client will cache responses for the duration of `cacheTTL` milliseconds. | ||
* If `cacheTTL` is 0, caching is disabled: | ||
* | ||
* @example | ||
* | ||
* ```typescript | ||
* // disable caching | ||
* const client = createDelegatedRoutingV1HttpApiClient('https://example.org', { cacheTTL: 0 }) | ||
* ``` | ||
* | ||
* ### Filtering with IPIP-484 | ||
* | ||
* The client can be configured to pass filter options to the delegated routing server as defined in IPIP-484. | ||
|
@@ -124,6 +138,12 @@ export interface DelegatedRoutingV1HttpApiClientInit extends FilterOptions { | |
* How long a request is allowed to take in ms (default: 30 seconds) | ||
*/ | ||
timeout?: number | ||
|
||
/** | ||
* How long to cache responses for in ms (default: 5 minutes) | ||
* If 0, caching is disabled | ||
*/ | ||
cacheTTL?: number | ||
} | ||
|
||
export interface GetIPNSOptions extends AbortOptions { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realised that this can be a problem if you have multiple instances of the client in scope as we do in Verified Fetch.
But even then, it's most likely that they all get stopped at the same time rather than individually.