-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mark
createLRUCache
as an internal utility (#3588)
- Loading branch information
Showing
4 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'graphql-yoga': patch | ||
--- | ||
|
||
Mark `createLRUCache` utility as deprecated, and export it as `_createLRUCache` marking it as an | ||
internal utility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,47 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-object-type */ | ||
import { LRUCache as LRU } from 'lru-cache'; | ||
|
||
/** | ||
* @deprecated In the next major, `createLRUCache` will be renamed to `_createLRUCache`, | ||
* and the current `createLRUCache` will be removed. | ||
*/ | ||
export const createLRUCache = _createLRUCache; | ||
|
||
/** | ||
* @deprecated In the next major, `LRUCacheOptions` will be renamed to `_LRUCacheOptions`, | ||
* and the current `LRUCacheOptions` will be removed. | ||
*/ | ||
export type LRUCacheOptions = _LRUCacheOptions; | ||
|
||
/** | ||
* @deprecated In the next major, `LRUCache` will be renamed to `_LRUCache`, | ||
* and the current `LRUCache` will be removed. | ||
*/ | ||
export type LRUCache<T extends {}> = _LRUCache<T>; | ||
|
||
const DEFAULT_MAX = 1024; | ||
const DEFAULT_TTL = 3_600_000; | ||
|
||
export type LRUCache<T extends {}> = LRU<string, T>; | ||
export interface LRUCacheOptions { | ||
/** | ||
* @internal This is an internal utility, and you should use it with your own risk. | ||
* This utility can have breaking changes in the future. | ||
*/ | ||
export type _LRUCache<T extends {}> = LRU<string, T>; | ||
/** | ||
* @internal This is an internal utility, and you should use it with your own risk. | ||
* This utility can have breaking changes in the future. | ||
*/ | ||
export interface _LRUCacheOptions { | ||
max?: number; | ||
ttl?: number; | ||
} | ||
|
||
export function createLRUCache<T extends {}>({ | ||
/** | ||
* @internal This is an internal utility, and you should use it with your own risk. | ||
* This utility can have breaking changes in the future. | ||
*/ | ||
export function _createLRUCache<T extends {}>({ | ||
max = DEFAULT_MAX, | ||
ttl = DEFAULT_TTL, | ||
}: LRUCacheOptions = {}) { | ||
}: _LRUCacheOptions = {}) { | ||
return new LRU<string, T>({ max, ttl }); | ||
} |