mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
全文搜索适配
This commit is contained in:
17
lib/cache/cache_manager.js
vendored
17
lib/cache/cache_manager.js
vendored
@@ -17,19 +17,20 @@ if (process.env.MONGO_DB_URL && process.env.MONGO_DB_NAME) {
|
||||
* @param {*} key
|
||||
* @returns
|
||||
*/
|
||||
export async function getDataFromCache(key) {
|
||||
if (!BLOG.ENABLE_CACHE) {
|
||||
export async function getDataFromCache(key, force) {
|
||||
if (BLOG.ENABLE_CACHE || force) {
|
||||
const dataFromCache = await api.getCache(key)
|
||||
if (JSON.stringify(dataFromCache) === '[]') {
|
||||
return null
|
||||
}
|
||||
return api.getCache(key)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
const dataFromCache = await api.getCache(key)
|
||||
if (JSON.stringify(dataFromCache) === '[]') {
|
||||
return null
|
||||
}
|
||||
return api.getCache(key)
|
||||
}
|
||||
|
||||
export async function setDataToCache(key, data) {
|
||||
if (!BLOG.ENABLE_CACHE || !data) {
|
||||
if (!data) {
|
||||
return
|
||||
}
|
||||
await api.setCache(key, data)
|
||||
|
||||
@@ -109,7 +109,7 @@ async function filterByMemCache(allPosts, keyword) {
|
||||
}
|
||||
for (const post of allPosts) {
|
||||
const cacheKey = 'page_block_' + post.id
|
||||
const page = await getDataFromCache(cacheKey)
|
||||
const page = await getDataFromCache(cacheKey, true)
|
||||
const tagContent = post.tags && Array.isArray(post.tags) ? post.tags.join(' ') : ''
|
||||
const categoryContent = post.category && Array.isArray(post.category) ? post.category.join(' ') : ''
|
||||
const articleInfo = post.title + post.summary + tagContent + categoryContent
|
||||
@@ -123,7 +123,7 @@ async function filterByMemCache(allPosts, keyword) {
|
||||
indexContent = appendText(indexContent, properties, 'caption')
|
||||
})
|
||||
}
|
||||
console.log('全文搜索缓存', cacheKey, page != null)
|
||||
// console.log('全文搜索缓存', cacheKey, page != null)
|
||||
post.results = []
|
||||
let hitCount = 0
|
||||
for (const i in indexContent) {
|
||||
|
||||
Reference in New Issue
Block a user