コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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;
            }
        }