public async Task <MembershipTableData> ReadRow(SiloAddress key) { try { MembershipTableData data = null; var val = await database.StringGetAsync(clusterId); if (!val.IsNull) { RedisMembershipCollection collection = serializer.Deserialize <RedisMembershipCollection>(val); data = collection.ToMembershipTableData(); } else { data = new MembershipTableData(_tableVersion); } return(data); } catch (Exception ex) { logger?.LogError(ex, "Redis membership table key '{0}' failed read row.", clusterId); throw ex; } }
public async Task <MembershipTableData> ReadAll() { logger?.LogInformation("It worked !!! :-)"); MembershipTableData data = null; try { while (true) { long ticks = DateTime.UtcNow.Ticks; await database.StringSetAsync("locktoken", ticks.ToString(), new TimeSpan(0, 0, 10)); var val = await database.StringGetAsync(clusterId); if (!val.IsNull) { RedisMembershipCollection collection = serializer.Deserialize <RedisMembershipCollection>(val); data = collection.ToMembershipTableData(); } else { data = new MembershipTableData(_tableVersion); } string tokenValue = await database.StringGetAsync("locktoken"); if (tokenValue != ticks.ToString()) { continue; } else { break; } } return(data); } catch (Exception ex) { logger?.LogError(ex, "Redis membership table key '{0}' failed read all.", clusterId); throw ex; } }