本文整理汇总了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());
}
}
示例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");
}
}