Skip to content

Commit

Permalink
cleanup(repo): handleMaybeCacheOnly -> handleStorage (#4696)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatOneBro committed Jun 20, 2024
1 parent b49784b commit 0dd281f
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 0dd281f

Please sign in to comment.