本文整理汇总了C#中RedisClient.Exists方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.Exists方法的具体用法?C# RedisClient.Exists怎么用?C# RedisClient.Exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedisClient
的用法示例。
在下文中一共展示了RedisClient.Exists方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestExists
public void TestExists()
{
using (var mock = new FakeRedisSocket(":1\r\n", ":0\r\n"))
using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
{
Assert.IsTrue(redis.Exists("test1"));
Assert.AreEqual("*2\r\n$6\r\nEXISTS\r\n$5\r\ntest1\r\n", mock.GetMessage());
Assert.IsFalse(redis.Exists("test2"));
Assert.AreEqual("*2\r\n$6\r\nEXISTS\r\n$5\r\ntest2\r\n", mock.GetMessage());
}
}
示例2: Delete
public void Delete(Guid personId)
{
var client = new RedisClient ();
var key = new PeopleKeys ().GetPersonKey (personId);
if (client.Exists (key))
client.Del (key);
}
示例3: TestExists
public void TestExists()
{
using(var mock = new MockConnector("localhost", 9999, ":1\r\n", ":0\r\n"))
using(var redis = new RedisClient(mock))
{
Assert.True(redis.Exists("test1"));
Assert.Equal("*2\r\n$6\r\nEXISTS\r\n$5\r\ntest1\r\n", mock.GetMessage());
Assert.False(redis.Exists("test2"));
Assert.Equal("*2\r\n$6\r\nEXISTS\r\n$5\r\ntest2\r\n", mock.GetMessage());
}
this.RealCall(redis =>
{
redis.MSet(new RedisDictionary { { "key1", "value1" }, { "key2", "value2" } });
Assert.True(redis.Exists("key1"));
Assert.True(redis.Exists("key2"));
Assert.False(redis.Exists("test3"));
});
}
示例4: Add
public void Add(BaseInstruction instruction)
{
var key = new InstructionKeys ().GetIdsKey (instruction.TargetType, instruction.TargetId);
var client = new RedisClient ();
var stringToAppend = instruction.Id.ToString();
if (client.Exists (key))
stringToAppend = "." + stringToAppend;
client.Append (key, stringToAppend);
}
示例5: Read
public Person[] Read(Guid tileId)
{
var client = new RedisClient ();
var key = new PeopleKeys ().GetPeopleKey (tileId);
if (!client.Exists (key))
return new Person[]{ };
else {
var json = client.Get (key);
var people = JsonToArray<Person> (json);
return people;
}
}
示例6: Read
public EngineInfo Read(Guid engineId)
{
var client = new RedisClient ();
var key = new EngineKeys ().GetInfoKey (engineId);
if (!client.Exists (key))
return null;
else {
var json = client.Get (key);
var engineInfo = JsonToEntity<EngineInfo> (json);
return engineInfo;
}
}
示例7: GetIds
public Guid[] GetIds()
{
var client = new RedisClient ();
var key = new EngineKeys().GetEngineIdsKey();
if (client.Exists (key)) {
var data = client.Get (key);
var idStrings = data.Split (',');
var ids = new List<Guid> ();
foreach (var idString in idStrings) {
ids.Add (Guid.Parse (idString));
}
return ids.ToArray ();
} else {
return new Guid[]{ };
}
}