Skip to content

Commit

Permalink
feat(server): prune cache
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Jun 11, 2024
1 parent 36e3492 commit edc2fc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/server/src/admin/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { registerApp } from '../app';

import { pruneResourcesCache } from '../query/resources';

import { syncDocuments } from './meili';
import { fixDmhyResources, refreshDmhyResources } from './dmhy';

export function registerAdmin() {
registerApp((app) => {
app.delete(`/admin/dmhy/resources/cache`, async (req) => {
await pruneResourcesCache();
return req.json({ ok: true });
});

app.post(`/admin/dmhy/resources`, async (req) => {
const r = await refreshDmhyResources();
return req.json(r);
Expand Down
4 changes: 4 additions & 0 deletions packages/server/src/query/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const logger = rootLogger.forkIntegrationLogger('detail');

const resourcesStorage = prefixStorage(storage, 'resources');

export async function pruneResourcesCache() {
await resourcesStorage.clear();
}

export async function queryResources(ctx: Context, filter: ResolvedFilterOptions) {
if (filter.search) {
const resp = await searchResources(filter.search.join(' '), filter);
Expand Down

0 comments on commit edc2fc4

Please sign in to comment.