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


C# RedisClient.SetEntry方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:nuxleus,项目名称:ServiceStack.Redis,代码行数:28,代码来源:MultiThreadedRedisClientIntegrationTests.cs

示例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));
			}
		}
开发者ID:nataren,项目名称:NServiceKit.Redis,代码行数:27,代码来源:ValueTypeExamples.cs

示例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"));
        }
开发者ID:JackBao,项目名称:ServiceStack.Redis,代码行数:11,代码来源:TwemproxyTests.cs


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