55 */
66
77import { AxiosAdapter , AxiosPromise } from 'axios' ;
8- import LRUCache from 'lru-cache' ;
98import buildSortedURL from './utils/buildSortedURL' ;
9+ import getDefaultLruCache , { ICacheLike } from './utils/getDefaultLruCache' ;
1010import isCacheLike from './utils/isCacheLike' ;
1111
1212declare module 'axios' {
@@ -19,14 +19,6 @@ declare module 'axios' {
1919const FIVE_MINUTES = 1000 * 60 * 5 ;
2020const CAPACITY = 100 ;
2121
22- export interface ICacheLike < T > {
23- get ( key : string ) : T | undefined ;
24-
25- set ( key : string , value : T , maxAge ?: number ) : boolean ;
26-
27- del ( key : string ) : void ;
28- }
29-
3022export type Options = {
3123 enabledByDefault ?: boolean ,
3224 cacheFlag ?: string ,
@@ -38,7 +30,7 @@ export default function cacheAdapterEnhancer(adapter: AxiosAdapter, options: Opt
3830 const {
3931 enabledByDefault = true ,
4032 cacheFlag = 'cache' ,
41- defaultCache = new LRUCache < string , AxiosPromise > ( { maxAge : FIVE_MINUTES , max : CAPACITY } ) ,
33+ defaultCache = getDefaultLruCache < AxiosPromise > ( { ttl : FIVE_MINUTES , max : CAPACITY } ) ,
4234 } = options ;
4335
4436 return config => {
@@ -50,7 +42,7 @@ export default function cacheAdapterEnhancer(adapter: AxiosAdapter, options: Opt
5042
5143 if ( method === 'get' && useCache ) {
5244
53- // if had provide a specified cache, then use it instead
45+ // if had provided a specified cache, then use it instead
5446 const cache : ICacheLike < AxiosPromise > = isCacheLike ( useCache ) ? useCache : defaultCache ;
5547
5648 // build the index according to the url and params
0 commit comments