How is it possible to optimize the update of an entity, when this entity is updated many times per second by request of the server ?. The method used for the update is developed as follows:
public async Task<bool> Update(T entity, string key)
{
try
{
MakeConnection();
var trans = _db.BeginTransaction();
var type = typeof(T);
var keyFactory = _db.CreateKeyFactory(type.Name);
var task = trans.Lookup(keyFactory.CreateKey(key));
if (task != null)
{
_cache.KeyCache[type.Name] = _db.CreateKeyFactory(type.Name);
var entities = _mapper.Map<Entity>(entity);
task = entities;
trans.Update(task);
}
await trans.CommitAsync();
}
catch (Exception e)
{
throw new InvalidOperationException($"An error occurred, {e}");
}
return true;
}
and this is the error:
InvalidOperationException: An error occurred, Grpc.Core.RpcException: Status(StatusCode=Aborted, Detail="too much contention on these datastore entities. please try again. entity groups: [(app=p~********, *********, "76fcb9c1-009e-****-b54f-68a45e9c****")]")