本文整理汇总了C#中RedisClient.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.GetValue方法的具体用法?C# RedisClient.GetValue怎么用?C# RedisClient.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedisClient
的用法示例。
在下文中一共展示了RedisClient.GetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
}
示例2: Can_connect_to_ssl_azure_redis
public void Can_connect_to_ssl_azure_redis()
{
using (var client = new RedisClient(connectionString))
{
client.Set("foo", "bar");
var foo = client.GetValue("foo");
foo.Print();
}
}
示例3: Can_connect_to_ssl_azure_redis_with_UrlFormat
public void Can_connect_to_ssl_azure_redis_with_UrlFormat()
{
var url = "redis://{0}?ssl=true&password={1}".Fmt(Host, Password.UrlEncode());
using (var client = new RedisClient(url))
{
client.Set("foo", "bar");
var foo = client.GetValue("foo");
foo.Print();
}
}
示例4: Transaction_fails_if_first_command
public void Transaction_fails_if_first_command()
{
var redis = new RedisClient(TestConfig.SingleHost);
using (var trans = redis.CreateTransaction())
{
trans.QueueCommand(r => r.IncrementValue("A"));
trans.Commit();
}
Assert.That(redis.GetValue("A"), Is.EqualTo("1"));
}
示例5: 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)
{
Debug.WriteLine("NullReferenceException StackTrace: \n" + ex.StackTrace);
}
catch (Exception ex)
{
Debug.WriteLine(String.Format("\t[[email protected]{0}]: {1} => {2}",
host, ex.GetType().Name, ex.Message));
}
}