Skip to content

Commit a112241

Browse files
authored
Update get-site-map.ts , add cache
see more: transitive-bullshit#597
1 parent 6af26e9 commit a112241

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/get-site-map.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import * as types from './types'
66
import { includeNotionIdInUrls } from './config'
77
import { getCanonicalPageId } from './get-canonical-page-id'
88
import { notion } from './notion-api'
9+
import ExpiryMap from 'expiry-map'
910

1011
const uuid = !!includeNotionIdInUrls
12+
const cache = new ExpiryMap(10000)
1113

1214
export async function getSiteMap(): Promise<types.SiteMap> {
1315
const partialSiteMap = await getAllPages(
@@ -22,7 +24,8 @@ export async function getSiteMap(): Promise<types.SiteMap> {
2224
}
2325

2426
const getAllPages = pMemoize(getAllPagesImpl, {
25-
cacheKey: (...args) => JSON.stringify(args)
27+
cacheKey: (...args) => JSON.stringify(args),
28+
cache
2629
})
2730

2831
async function getAllPagesImpl(

0 commit comments

Comments
 (0)