Skip to content

Commit

Permalink
fix: revalidate cache
Browse files Browse the repository at this point in the history
chronark committed Oct 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 475973c commit 791b789
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/api/src/pkg/audit.ts
Original file line number Diff line number Diff line change
@@ -42,8 +42,9 @@ export async function insertGenericAuditLogs(
const { cache, logger, db } = c.get("services");

for (const log of arr) {
const cacheKey = [log.workspaceId, log.bucket].join(":");
let { val: bucket, err } = await cache.auditLogBucketByWorkspaceIdAndName.swr(
[log.workspaceId, log.bucket].join(":"),
cacheKey,
async () => {
const bucket = await (tx ?? db.primary).query.auditLogBucket.findFirst({
where: (table, { eq, and }) =>
@@ -74,6 +75,7 @@ export async function insertGenericAuditLogs(
retentionDays: 90,
});
bucket = { id: bucketId };
await cache.auditLogBucketByWorkspaceIdAndName.remove(cacheKey);
}

const auditLogId = newId("auditLog");

0 comments on commit 791b789

Please sign in to comment.