Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(repo): handleMaybeCacheOnly -> handleStorage #4696

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
cleanup(repo): handleMaybeCacheOnly -> handleStorage
  • Loading branch information
ThatOneBro committed Jun 19, 2024
commit c8a7cbf36d674c7ac830d5aa4f17e8dfe6230b9a
7 changes: 4 additions & 3 deletions packages/server/src/fhir/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ export class Repository extends BaseRepository implements FhirRepository<PoolCli
}

await this.handleBinaryUpdate(existing, result);
await this.handleMaybeCacheOnly(result, create);
await setCacheEntry(result);
await this.handleStorage(result, create);
await addBackgroundJobs(result, { interaction: create ? 'create' : 'update' });
this.removeHiddenFields(result);
return result;
Expand Down Expand Up @@ -646,7 +645,7 @@ export class Repository extends BaseRepository implements FhirRepository<PoolCli
resource.data = undefined;
}

private async handleMaybeCacheOnly(result: Resource, create: boolean): Promise<void> {
private async handleStorage(result: Resource, create: boolean): Promise<void> {
if (!this.isCacheOnly(result)) {
await this.writeToDatabase(result, create);
} else if (result.resourceType === 'Subscription' && result.channel?.type === 'websocket') {
Expand All @@ -658,6 +657,8 @@ export class Repository extends BaseRepository implements FhirRepository<PoolCli
// WebSocket Subscriptions are also cache-only, but also need to be added to a special cache key
await redis.sadd(`medplum:subscriptions:r4:project:${project}:active`, `Subscription/${result.id}`);
}
// Add this resource to cache
await setCacheEntry(result);
}

/**
Expand Down
Loading