Skip to content

Commit

Permalink
refactor: add comments to keys-api-service
Browse files Browse the repository at this point in the history
  • Loading branch information
eddort committed Oct 29, 2024
1 parent 159ab96 commit c153679
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/keys-api/keys-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { DeepReadonly } from 'common/ts-utils';

@Injectable()
export class KeysApiService {
// Do not use this value in a straightforward manner
// It can be used in parallel at the moment in `getKeys`
private cachedKeys?: DeepReadonly<KeyListResponse>;
constructor(
@Inject(WINSTON_MODULE_NEST_PROVIDER) protected logger: LoggerService,
Expand Down Expand Up @@ -125,6 +127,9 @@ export class KeysApiService {
cachedELBlockSnapshot: this.cachedKeys?.meta.elBlockSnapshot,
});

// delete old cache to optimize memory performance
this.cachedKeys = undefined;

const result = await this.fetch<KeyListResponse>(`/v1/keys`);

this.logger.log('Keys successfully updated in cache from KeysAPI', {
Expand All @@ -139,6 +144,7 @@ export class KeysApiService {
);

this.cachedKeys = result;
// return exactly `result` because this function can be used in parallel
return result;
}

Expand Down

0 comments on commit c153679

Please sign in to comment.