adding caching to get value sum
All checks were successful
API and ETL Build / build_etl (push) Successful in 3s
API and ETL Build / build_api (push) Successful in 10s

This commit is contained in:
Jose Henrique 2025-06-13 11:47:39 -03:00
parent 23256245a0
commit 87a98fefb1

View File

@ -78,10 +78,14 @@ namespace OpenCand.API.Repository
public async Task<List<GetValueSumResponse>> GetValueSum(string query, Dictionary<string, object>? parameters = null)
{
using (var connection = new NpgsqlConnection(ConnectionString))
string cacheKey = GenerateCacheKey(query.GetHashCode().ToString());
return await GetOrSetCacheAsync(cacheKey, async () =>
{
return (await connection.QueryAsync<GetValueSumResponse>(query, parameters)).AsList();
}
using (var connection = new NpgsqlConnection(ConnectionString))
{
return (await connection.QueryAsync<GetValueSumResponse>(query, parameters)).AsList();
}
}) ?? new List<GetValueSumResponse>();
}
}
}