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


C# RedisClient.SScan方法代码示例

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


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

示例1: TestSScan

        public void TestSScan()
        {
            string reply = "*2\r\n$1\r\n0\r\n*2\r\n$5\r\ntest1\r\n$5\r\ntest2\r\n";
            using(var mock = new MockConnector("localhost", 9999, reply, reply, reply, reply))
            using(var redis = new RedisClient(mock))
            {
                var resp = (redis.SScan("test", 0) as RedisScan<BinaryValue>).GetEnumerator() as RedisScan<BinaryValue>.Enumerator;
                resp.MoveNext();
                Assert.Equal(0, resp.Cursor);
                Assert.Equal(1, resp.Items.Length);
                Assert.Equal("test1", (string)resp.Current);
                resp.MoveNext();
                Assert.Equal(0, resp.Cursor);
                Assert.Equal(0, resp.Items.Length);
                Assert.Equal("test2", (string)resp.Current);
                Assert.Equal("*3\r\n$5\r\nSSCAN\r\n$4\r\ntest\r\n$1\r\n0\r\n", mock.GetMessage());

                var response2 = redis.SScan("test", 0, pattern: "*").ToArray();
                Assert.Equal("*5\r\n$5\r\nSSCAN\r\n$4\r\ntest\r\n$1\r\n0\r\n$5\r\nMATCH\r\n$1\r\n*\r\n", mock.GetMessage());

                var response3 = redis.SScan("test", 0, count: 5).ToArray();
                Assert.Equal("*5\r\n$5\r\nSSCAN\r\n$4\r\ntest\r\n$1\r\n0\r\n$5\r\nCOUNT\r\n$1\r\n5\r\n", mock.GetMessage());

                var response4 = redis.SScan("test", 0, "*", 5).ToArray();
                Assert.Equal("*7\r\n$5\r\nSSCAN\r\n$4\r\ntest\r\n$1\r\n0\r\n$5\r\nMATCH\r\n$1\r\n*\r\n$5\r\nCOUNT\r\n$1\r\n5\r\n", mock.GetMessage());
            }
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:27,代码来源:RedisSetTests.cs

示例2: TestSScan

        public void TestSScan()
        {
            string reply = "*2\r\n$2\r\n23\r\n*2\r\n$5\r\ntest1\r\n$5\r\ntest2\r\n";
            using (var mock = new FakeRedisSocket(reply, reply, reply, reply))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                var response1 = redis.SScan("test", 0);
                Assert.AreEqual(23, response1.Cursor);
                Assert.AreEqual(2, response1.Items.Length);
                Assert.AreEqual("test1", response1.Items[0]);
                Assert.AreEqual("test2", response1.Items[1]);
                Assert.AreEqual("*3\r\n$5\r\nSSCAN\r\n$4\r\ntest\r\n$1\r\n0\r\n", mock.GetMessage(), "Basic test");

                var response2 = redis.SScan("test", 0, pattern: "*");
                Assert.AreEqual("*5\r\n$5\r\nSSCAN\r\n$4\r\ntest\r\n$1\r\n0\r\n$5\r\nMATCH\r\n$1\r\n*\r\n", mock.GetMessage(), "Pattern test");

                var response3 = redis.SScan("test", 0, count: 5);
                Assert.AreEqual("*5\r\n$5\r\nSSCAN\r\n$4\r\ntest\r\n$1\r\n0\r\n$5\r\nCOUNT\r\n$1\r\n5\r\n", mock.GetMessage(), "Count test");

                var response4 = redis.SScan("test", 0, "*", 5);
                Assert.AreEqual("*7\r\n$5\r\nSSCAN\r\n$4\r\ntest\r\n$1\r\n0\r\n$5\r\nMATCH\r\n$1\r\n*\r\n$5\r\nCOUNT\r\n$1\r\n5\r\n", mock.GetMessage(), "Pattern + Count test");
            }
        }
开发者ID:DTBruce,项目名称:csredis,代码行数:23,代码来源:SetTests.cs


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