当前位置: 首页>>代码示例>>C#>>正文


C# RedisClient.FlushAll方法代码示例

本文整理汇总了C#中RedisClient.FlushAll方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.FlushAll方法的具体用法?C# RedisClient.FlushAll怎么用?C# RedisClient.FlushAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RedisClient的用法示例。


在下文中一共展示了RedisClient.FlushAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateServer

        RedisMqServer CreateServer()
        {
            using (var redis = new RedisClient())
                redis.FlushAll();

            var mqServer = new RedisMqServer(new BasicRedisClientManager());
            mqServer.RegisterHandler<Spin0>(m => new Spin0 { Id = counter.Spin0++ });

            mqServer.RegisterHandler<Spin10>(m => {
                var sw = Stopwatch.StartNew();
                while (sw.ElapsedMilliseconds < 10) Thread.SpinWait(100000);
                return new Spin10 { Id = counter.Spin10++ };
            });
            mqServer.RegisterHandler<Spin100>(m => {
                var sw = Stopwatch.StartNew();
                while (sw.ElapsedMilliseconds < 100) Thread.SpinWait(100000);
                return new Spin100 { Id = counter.Spin100++ };
            });
            mqServer.RegisterHandler<Spin1000>(m => {
                var sw = Stopwatch.StartNew();
                while (sw.ElapsedMilliseconds < 1000) Thread.SpinWait(100000);
                return new Spin1000 { Id = counter.Spin1000++ };
            });


            return mqServer;
        }
开发者ID:adam-26,项目名称:ServiceStack.Redis,代码行数:27,代码来源:RedisMqServerSpinServerTests.cs

示例2: OnTestFixtureSetUp

		public void OnTestFixtureSetUp()
		{
			using (var redisClient = new RedisClient(TestConfig.SingleHost))
			{
				redisClient.FlushAll();
			}
		}
开发者ID:modulexcite,项目名称:ServiceStack.Redis,代码行数:7,代码来源:SimpleLocks.cs

示例3: Does_retry_failed_commands_auth

        public void Does_retry_failed_commands_auth()
        {
            // -> Redis must have "requirepass testpassword" in config
            var connstr = "[email protected]";
            RedisStats.Reset();

            var redisCtrl = new RedisClient(connstr); //RedisConfig.DefaultHost
            redisCtrl.FlushAll();
            redisCtrl.SetClient("redisCtrl");

            var redis = new RedisClient(connstr);
            redis.SetClient("redisRetry");

            var clientInfo = redisCtrl.GetClientsInfo();
            var redisId = clientInfo.First(m => m["name"] == "redisRetry")["id"];
            Assert.That(redisId.Length, Is.GreaterThan(0));

            Assert.That(redis.IncrementValue("retryCounter"), Is.EqualTo(1));

            redis.OnBeforeFlush = () =>
            {
                redisCtrl.KillClients(withId: redisId);
            };

            Assert.That(redis.IncrementValue("retryCounter"), Is.EqualTo(2));
            Assert.That(redis.Get<int>("retryCounter"), Is.EqualTo(2));

            Assert.That(RedisStats.TotalRetryCount, Is.EqualTo(1));
            Assert.That(RedisStats.TotalRetrySuccess, Is.EqualTo(1));
            Assert.That(RedisStats.TotalRetryTimedout, Is.EqualTo(0));
        }
开发者ID:ServiceStack,项目名称:ServiceStack.Redis,代码行数:31,代码来源:AuthIssue.cs

示例4: CreateClient

 private IRedisClient CreateClient(bool flushAll = true)
 {
     var client = new RedisClient(6379);
     if(flushAll)
         client.FlushAll();
     return client;
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:7,代码来源:RedisStreamTests.cs

示例5: Does_Timeout_with_repeated_SocketException

        public void Does_Timeout_with_repeated_SocketException()
        {
            RedisConfig.Reset();
            RedisConfig.DefaultRetryTimeout = 100;

            var redis = new RedisClient(RedisConfig.DefaultHost);
            redis.FlushAll();

            Assert.That(redis.IncrementValue("retryCounter"), Is.EqualTo(1));

            redis.OnBeforeFlush = () =>
            {
                throw new SocketException();
            };

            try
            {
                redis.IncrementValue("retryCounter");
                Assert.Fail("Should throw");
            }
            catch (RedisException ex)
            {
                Assert.That(ex.Message, Is.StringStarting("Exceeded timeout"));

                redis.OnBeforeFlush = null;
                Assert.That(redis.Get<int>("retryCounter"), Is.EqualTo(1));

                Assert.That(RedisStats.TotalRetryCount, Is.GreaterThan(1));
                Assert.That(RedisStats.TotalRetrySuccess, Is.EqualTo(0));
                Assert.That(RedisStats.TotalRetryTimedout, Is.EqualTo(1));
            }

            RedisConfig.Reset();
        }
开发者ID:CatomStudio,项目名称:ServiceStack.Redis,代码行数:34,代码来源:RetryCommandTests.cs

示例6: Does_retry_failed_commands

        public void Does_retry_failed_commands()
        {
            //LogManager.LogFactory = new ConsoleLogFactory(debugEnabled: true);

            RedisStats.Reset();

            var redisCtrl = new RedisClient(RedisConfig.DefaultHost);
            redisCtrl.FlushAll();
            redisCtrl.SetClient("redisCtrl");

            var redis = new RedisClient(RedisConfig.DefaultHost);
            redis.SetClient("redisRetry");

            var clientInfo = redisCtrl.GetClientsInfo();
            var redisId = clientInfo.First(m => m["name"] == "redisRetry")["id"];
            Assert.That(redisId.Length, Is.GreaterThan(0));

            Assert.That(redis.IncrementValue("retryCounter"), Is.EqualTo(1));

            redis.OnBeforeFlush = () =>
            {
                redisCtrl.KillClients(withId: redisId);
            };

            Assert.That(redis.IncrementValue("retryCounter"), Is.EqualTo(2));
            Assert.That(redis.Get<int>("retryCounter"), Is.EqualTo(2));

            Assert.That(RedisStats.TotalRetryCount, Is.EqualTo(1));
            Assert.That(RedisStats.TotalRetrySuccess, Is.EqualTo(1));
            Assert.That(RedisStats.TotalRetryTimedout, Is.EqualTo(0));
        }
开发者ID:CatomStudio,项目名称:ServiceStack.Redis,代码行数:31,代码来源:RetryCommandTests.cs

示例7: OnBeforeEachTest

        public override void OnBeforeEachTest()
        {
            //base.OnBeforeEachTest();

            //Run on local build server
            Redis = new RedisClient(TestConfig.SingleHost);
            Redis.FlushAll();
        }
开发者ID:modulexcite,项目名称:ServiceStack.Redis,代码行数:8,代码来源:RedisClientEvalTests.cs

示例8: OnBeforeEachTest

        public override void OnBeforeEachTest()
        {
            //base.OnBeforeEachTest();

            //Run on local build server
            Redis = new RedisClient("192.168.2.16");
            Redis.FlushAll();
        }
开发者ID:appfigures,项目名称:ServiceStack.Redis,代码行数:8,代码来源:RedisClientEvalTests.cs

示例9: Test_on_old_redisserver

        public void Test_on_old_redisserver()
        {
            var redis = new RedisClient("10.0.0.14");
            //var redis = new RedisClient();
            redis.FlushAll();

            //redis.ExpireEntryIn("key", TimeSpan.FromDays(14));

            redis.Set("key", "value", TimeSpan.FromDays(14));

            var value = redis.Get("key");

            value.FromUtf8Bytes().Print();
        }
开发者ID:CatomStudio,项目名称:ServiceStack.Redis,代码行数:14,代码来源:RedisHyperLogTests.cs

示例10: SetUp

        public void SetUp()
        {
            if (client != null)
            {
                client.Dispose();
                client = null;
            }
            client = new RedisClient(TestConfig.SingleHost);
            client.FlushAll();

            redis = client.GetTypedClient<CustomType>();

            List = redis.Lists[ListId];
            List2 = redis.Lists[ListId2];
        }
开发者ID:nataren,项目名称:NServiceKit.Redis,代码行数:15,代码来源:RedisClientListTestExtra.cs

示例11: Can_Retrieve_DomainEvents

        public void Can_Retrieve_DomainEvents()
        {
            var userId = Guid.NewGuid();
            var client = new RedisClient(TestConfig.SingleHost);
            client.FlushAll();

            client.As<DomainEvent>().Lists["urn:domainevents-" + userId].Add(new UserPromotedEvent { UserId = userId });


            var users = client.As<DomainEvent>().Lists["urn:domainevents-" + userId];

            Assert.That(users.Count, Is.EqualTo(1));

            var userPromoEvent = (UserPromotedEvent)users[0];
            Assert.That(userPromoEvent.UserId, Is.EqualTo(userId));
        }
开发者ID:Eddie0330,项目名称:ServiceStack.Redis,代码行数:16,代码来源:DomainEventsTests.cs

示例12: Can_run_series_of_operations_sequentially

		public void Can_run_series_of_operations_sequentially()
		{
			var before = Stopwatch.GetTimestamp();

			const int noOfConcurrentClients = 64; //WaitHandle.WaitAll limit is <= 64

			using (var redisClient = new RedisClient(TestConfig.SingleHost))
			{
				redisClient.FlushAll();

				for (var i = 0; i < noOfConcurrentClients; i++)
				{
					var clientNo = i;
					UseClient(redisClient, clientNo);
				}
			}

			Debug.WriteLine(String.Format("Completed in {0} ticks", (Stopwatch.GetTimestamp() - before)));
		}
开发者ID:Chevkio,项目名称:ServiceStack.Redis,代码行数:19,代码来源:RedisRegressionTestRun.cs

示例13: Can_Add_to_Hyperlog

        public void Can_Add_to_Hyperlog()
        {
            var redis = new RedisClient("10.0.0.14");
            redis.FlushAll();

            redis.AddToHyperLog("hyperlog", "a", "b", "c");
            redis.AddToHyperLog("hyperlog", "c", "d");

            var count = redis.CountHyperLog("hyperlog");

            Assert.That(count, Is.EqualTo(4));

            redis.AddToHyperLog("hyperlog2", "c", "d", "e", "f");

            redis.MergeHyperLogs("hypermerge", "hyperlog", "hyperlog2");

            var mergeCount = redis.CountHyperLog("hypermerge");

            Assert.That(mergeCount, Is.EqualTo(6));
        }
开发者ID:CatomStudio,项目名称:ServiceStack.Redis,代码行数:20,代码来源:RedisHyperLogTests.cs

示例14: Does_retry_failed_commands_with_SocketException

        public void Does_retry_failed_commands_with_SocketException()
        {
            RedisStats.Reset();

            var redis = new RedisClient(RedisConfig.DefaultHost);
            redis.FlushAll();

            Assert.That(redis.IncrementValue("retryCounter"), Is.EqualTo(1));

            redis.OnBeforeFlush = () =>
            {
                redis.OnBeforeFlush = null;
                throw new SocketException();
            };

            Assert.That(redis.IncrementValue("retryCounter"), Is.EqualTo(2));
            Assert.That(redis.Get<int>("retryCounter"), Is.EqualTo(2));

            Assert.That(RedisStats.TotalRetryCount, Is.EqualTo(1));
            Assert.That(RedisStats.TotalRetrySuccess, Is.EqualTo(1));
            Assert.That(RedisStats.TotalRetryTimedout, Is.EqualTo(0));
        }
开发者ID:CatomStudio,项目名称:ServiceStack.Redis,代码行数:22,代码来源:RetryCommandTests.cs

示例15: CreateServer

        RedisMqServer CreateServer()
        {
            using (var redis = new RedisClient())
                redis.FlushAll();

            var mqServer = new RedisMqServer(new BasicRedisClientManager());
            mqServer.RegisterHandler<Wait0>(m => new Wait0 { Id = counter.Wait0++ });

            mqServer.RegisterHandler<Wait10>(m => {
                Thread.Sleep(10);
                return new Wait10 { Id = counter.Wait10++ };
            });
            mqServer.RegisterHandler<Wait100>(m => {
                Thread.Sleep(100);
                return new Wait100 { Id = counter.Wait100++ };
            });
            mqServer.RegisterHandler<Wait1000>(m => {
                Thread.Sleep(1000);
                return new Wait1000 { Id = counter.Wait1000++ };
            });


            return mqServer;
        }
开发者ID:Termina1,项目名称:ServiceStack.Redis,代码行数:24,代码来源:RedisMqServerMultiServerTests.cs


注:本文中的RedisClient.FlushAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。