Skip to content

Commit

Permalink
fix cache cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
juandjara committed Nov 13, 2023
1 parent e8515dc commit 19733af
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/lib/cache.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function getCachedFiles(repo: string, branch: string) {
export async function deleteAllCaches(repo: string) {
return withRedis(async (db) => {
const cacheKeys = await db.smembers(`caches:${repo}`)
await db.del(cacheKeys)
return await db.del(`caches:${repo}`, ...cacheKeys)
})
}

Expand Down
3 changes: 2 additions & 1 deletion app/lib/projects.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ export async function deleteDraft(project: Project, path: string) {
export async function deleteAllDrafts(project: Project) {
return withRedis(async (db) => {
const draftKeys = await db.smembers(`drafts:${project.repo}`)
await db.del(draftKeys)
console.log(draftKeys)
return await db.del(`drafts:${project.repo}`, ...draftKeys)
})
}

Expand Down
8 changes: 4 additions & 4 deletions app/routes/p/$project/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export const action: ActionFunction = async ({ request, params }) => {
}

if (op === 'clearCache') {
await deleteAllCaches(project.repo)
flashMessage = 'Cache cleared successfully'
const num = await deleteAllCaches(project.repo)
flashMessage = `Cache cleared successfully. Cleared ${num} files.`
}

if (op === 'removeDrafts') {
await deleteAllDrafts(project)
flashMessage = 'Drafts removed successfully'
const num = await deleteAllDrafts(project)
flashMessage = `Drafts removed successfully. Removed ${num} drafts.`
}

const headers = new Headers({
Expand Down

0 comments on commit 19733af

Please sign in to comment.