Skip to content

Commit 60ec93a

Browse files
authored
fix(routes/mercari): use item updated time in cache key (#20726)
* Revert "fix(routes/mercari): set cache max age to routeExpire (#20653)" This reverts commit 7fc7a62. * fix(routes/mercari): use item updated time in cache key
1 parent 1efb6d0 commit 60ec93a

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

lib/routes/mercari/keyword.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { config } from '@/config';
21
import type { Route } from '@/types';
32
import cache from '@/utils/cache';
43

@@ -59,9 +58,7 @@ async function handler(ctx) {
5958
const { sort, order, status, keyword } = ctx.req.param();
6059
const statusArray = MercariStatus[status] ? [MercariStatus[status]] : [];
6160
const searchItems = (await fetchSearchItems(MercariSort[sort], MercariOrder[order], statusArray, keyword)).items;
62-
const items = await Promise.all(
63-
searchItems.map((item) => cache.tryGet(`mercari:${item.id}`, async () => await fetchItemDetail(item.id, item.itemType).then((detail) => formatItemDetail(detail)), config.cache.routeExpire, false))
64-
);
61+
const items = await Promise.all(searchItems.map((item) => cache.tryGet(`mercari:${item.id}:${item.updated}`, async () => await fetchItemDetail(item.id, item.itemType).then((detail) => formatItemDetail(detail)))));
6562

6663
return {
6764
title: `${keyword} の検索結果`,

lib/routes/mercari/search.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { config } from '@/config';
21
import type { Route } from '@/types';
32
import cache from '@/utils/cache';
43

@@ -88,9 +87,7 @@ async function handler(ctx) {
8887
const { keyword, sort, order, status, options } = parseSearchQuery(queryString);
8988
const searchItems = (await fetchSearchItems(sort, order, status, keyword, options)).items;
9089

91-
const items = await Promise.all(
92-
searchItems.map((item) => cache.tryGet(`mercari:${item.id}`, async () => await fetchItemDetail(item.id, item.itemType).then((detail) => formatItemDetail(detail)), config.cache.routeExpire, false))
93-
);
90+
const items = await Promise.all(searchItems.map((item) => cache.tryGet(`mercari:${item.id}:${item.updated}`, async () => await fetchItemDetail(item.id, item.itemType).then((detail) => formatItemDetail(detail)))));
9491

9592
return {
9693
title: `${keyword} の検索結果`,

0 commit comments

Comments
 (0)