添加博客渲染缓存

This commit is contained in:
2026-04-07 12:57:47 +08:00
parent ca1cf10aa8
commit 1b8bd19370
4 changed files with 69 additions and 8 deletions

16
src/lib/markdoc-cache.ts Normal file
View File

@ -0,0 +1,16 @@
import type { RenderableTreeNode } from '@markdoc/markdoc'
import KeyV from 'keyv'
import { createHash } from 'node:crypto'
const markdocVersion = '1'
export const markdocCache = new KeyV<RenderableTreeNode>({
namespace: `markdoc-cache-${markdocVersion}`,
ttl: 1000 * 60 * 60 * 24 * 7,
})
export const generateCacheKey = (content: string) => {
return createHash('sha256')
.update(content)
.update(markdocVersion)
.digest('hex')
}