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


C# RedisClient.FlushDb方法代码示例

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


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

示例1: OnBeforeEachTest

		public virtual void OnBeforeEachTest()
		{
			if (Redis != null) Redis.Dispose();
			Redis = new RedisClient(TestConfig.SingleHost);
			Redis.FlushDb();
			RedisTyped = Redis.As<CacheRecord>();
		}
开发者ID:Chevkio,项目名称:ServiceStack.Redis,代码行数:7,代码来源:RedisTypedClientTests.cs

示例2: FlushDbTest

 public void FlushDbTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "+OK\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.True(redis.FlushDb());
         Assert.Equal("*1\r\n$7\r\nFLUSHDB\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisServerTests.cs

示例3: Can_failover_MqServer_at_runtime

        public void Can_failover_MqServer_at_runtime()
        {
            const int iterations = 100;
            var failoverHost = "redis-failover:6379";
            var localClient = new RedisClient("localhost:6379");

            localClient.FlushDb();
            var failoverClient = new RedisClient(failoverHost);
            failoverClient.FlushDb();

            var clientManager = new PooledRedisClientManager(new[] { "localhost" });
            var mqHost = new RedisMqServer(clientManager);

            var map = new Dictionary<string, int>();
            var received = 0;
            mqHost.RegisterHandler<Msg>(c =>
            {
                var dto = c.GetBody();
                received++;
                int count;
                map.TryGetValue(dto.Host, out count);
                map[dto.Host] = count + 1;

                lock (clientManager)
                {
                    "Received #{0} from {1}".Print(received, dto.Host);
                    if (received == iterations)
                        Monitor.Pulse(clientManager);
                }

                return null;
            });

            mqHost.Start();

            RunMqInLoop(mqHost, iterations: iterations, callback: () =>
            {
                lock (clientManager)
                    "{0} msgs were published.".Print(iterations);
            });

            Thread.Sleep(500);

            clientManager.FailoverTo(failoverHost);

            lock (clientManager)
                Monitor.Wait(clientManager);

            map.PrintDump();
            "localclient inq: {0}, outq: {1}".Print(
                localClient.GetListCount("mq:Msg.inq"),
                localClient.GetListCount("mq:Msg.outq"));
            "failoverClient inq: {0}, outq: {1}".Print(
                failoverClient.GetListCount("mq:Msg.inq"),
                failoverClient.GetListCount("mq:Msg.outq"));

            Assert.That(received, Is.EqualTo(100));
            Assert.That(map.Count, Is.EqualTo(2));
            var msgsFromAllHosts = 0;
            foreach (var count in map.Values)
            {
                Assert.That(count, Is.GreaterThan(0));
                msgsFromAllHosts += count;
            }
            Assert.That(msgsFromAllHosts, Is.EqualTo(iterations));
        }
开发者ID:modulexcite,项目名称:ServiceStack.Redis,代码行数:66,代码来源:RedisFailoverTests.cs

示例4: GetRedisClient

 public RedisClient GetRedisClient()
 {
     var client = new RedisClient(TestConfig.SingleHost);
     client.FlushDb();
     return client;
 }
开发者ID:EvgeniyProtas,项目名称:servicestack,代码行数:6,代码来源:RedisClientTestsBase.cs

示例5: FlushDbTest

 public void FlushDbTest()
 {
     using (var mock = new FakeRedisSocket("+OK\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual("OK", redis.FlushDb());
         Assert.AreEqual("*1\r\n$7\r\nFLUSHDB\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:ServerTests.cs


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