Redis
 sql >> Database >  >> NoSQL >> Redis

StackExchange TimeoutException quando si tenta di inserire 750 elementi in 2 set in redis

Quanto segue va bene e riporta 10 ms localmente. Sarei molto interessato se potessi riempire un po' gli spazi vuoti in modo da poter fare un test rappresentativo che riproduca il problema. Nota che qu=0, qs=3 mi dice che al momento del timeout, stiamo aspettando che il server redis risponda. Ovviamente la larghezza di banda e la latenza locali sarebbero interessanti, ma fondamentalmente dovrebbe funzionare . Sarei anche interessato a sapere a cosa è impostato il timeout di sincronizzazione.

using System.Diagnostics;
using System.Linq;
using NUnit.Framework;

namespace StackExchange.Redis.Tests.Issues
{
    [TestFixture]
    public class SO22786599 : TestBase
    {
        [Test]
        public void Execute()
        {
            string CurrentIdsSetDbKey = Me() + ".x";
            string CurrentDetailsSetDbKey = Me() + ".y";

            RedisValue[] stringIds = Enumerable.Range(1, 750).Select(i => (RedisValue)(i + " id")).ToArray();
            RedisValue[] stringDetails = Enumerable.Range(1, 750).Select(i => (RedisValue)(i + " detail")).ToArray();

            using (var conn = Create())
            {
                var db = conn.GetDatabase();
                var tran = db.CreateTransaction();

                tran.SetAddAsync(CurrentIdsSetDbKey, stringIds);
                tran.SetAddAsync(CurrentDetailsSetDbKey, stringDetails);

                var watch = Stopwatch.StartNew();
                var isOperationSuccessful = tran.Execute();
                watch.Stop();
                System.Console.WriteLine("{0}ms", watch.ElapsedMilliseconds);
                Assert.IsTrue(isOperationSuccessful);                
            }
        }
    }
}