本文整理汇总了C#中RedisClient.SetEntry方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.SetEntry方法的具体用法?C# RedisClient.SetEntry怎么用?C# RedisClient.SetEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedisClient
的用法示例。
在下文中一共展示了RedisClient.SetEntry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UseClient
private static void UseClient(RedisClient client, int clientNo)
{
var host = "";
try
{
host = client.Host;
Log("Client '{0}' is using '{1}'", clientNo, client.Host);
var testClientKey = "test:" + host + ":" + clientNo;
client.SetEntry(testClientKey, testData);
var result = client.GetValue(testClientKey) ?? "";
Log("\t{0} => {1} len {2} {3} len", testClientKey,
testData.Length, testData.Length == result.Length ? "==" : "!=", result.Length);
}
catch (NullReferenceException ex)
{
Console.WriteLine("NullReferenceException StackTrace: \n" + ex.StackTrace);
}
catch (Exception ex)
{
Console.WriteLine("\t[[email protected]{0}]: {1} => {2}",
host, ex.GetType().Name, ex.Message);
}
}
示例2: Working_with_int_values
public void Working_with_int_values()
{
const string intKey = "intkey";
const int intValue = 1;
//STORING AN INT USING THE BASIC CLIENT
using (var redisClient = new RedisClient(TestConfig.SingleHost))
{
redisClient.SetEntry(intKey, intValue.ToString());
string strGetIntValue = redisClient.GetValue(intKey);
int toIntValue = int.Parse(strGetIntValue);
Assert.That(toIntValue, Is.EqualTo(intValue));
}
//STORING AN INT USING THE GENERIC CLIENT
using (var redisClient = new RedisClient(TestConfig.SingleHost))
{
//Create a generic client that treats all values as ints:
IRedisTypedClient<int> intRedis = redisClient.GetTypedClient<int>();
intRedis.SetEntry(intKey, intValue);
var toIntValue = intRedis.GetValue(intKey);
Assert.That(toIntValue, Is.EqualTo(intValue));
}
}
示例3: Can_connect_to_twemproxy
public void Can_connect_to_twemproxy()
{
var redis = new RedisClient("10.0.0.14", 22121) {
//ServerVersionNumber = 2611
};
//var redis = new RedisClient("10.0.0.14");
redis.SetEntry("foo", "bar");
var foo = redis.GetEntry("foo");
Assert.That(foo, Is.EqualTo("bar"));
}