Skip to content

Commit

Permalink
Changes return from BalanceCache from IEnumerable to ICollection
Browse files Browse the repository at this point in the history
  • Loading branch information
Chingling152 committed Apr 18, 2024
1 parent 2e04190 commit 0198082
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface IBalancesCache
{
Task AddAsync(BalanceModel balance);
Task AddAsync(IEnumerable<BalanceModel> balances);
Task<IEnumerable<BalanceModel>> GetByAccountAsync(Guid accountId);
Task<ICollection<BalanceModel>> GetByAccountAsync(Guid accountId);
Task<BalanceModel?> GetAsync(Guid id);
Task RemoveAsync(Guid id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ await this.cache.SetAsync(
}
}

public async Task<IEnumerable<BalanceModel>?> GetByAccountAsync(Guid accountId)
public async Task<ICollection<BalanceModel>?> GetByAccountAsync(Guid accountId)
{
var prefix = $"{ACCOUNT_PREFIX}:{accountId}:balances";
var result = await this.cache.GetAsync(prefix);
Expand All @@ -106,7 +106,7 @@ await this.cache.SetAsync(
}

this.logger.LogInformation("Balances from account {id} found in cache", accountId);
return result.FromByteArray<BalanceModel[]>() ?? null;
return result.FromByteArray<BalanceModel[]>() ?? Array.Empty<BalanceModel>();
}

public async Task RemoveAsync(Guid id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public async Task<int> DeleteAsync(Guid id)
public async Task<ICollection<BalanceModel>> GetAllByAccountAsync(Guid accountId)
{
var balances = await this.cache.GetByAccountAsync(accountId);
if(balances == null)
return Array.Empty<BalanceModel>();
if(balances != null)
return balances;

var entities = await this.repository.GetAsync(x => x.AccountId == accountId);

Expand Down

0 comments on commit 0198082

Please sign in to comment.