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


C# RedisClient.Set方法代码示例

本文整理汇总了C#中RedisClient.Set方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.Set方法的具体用法?C# RedisClient.Set怎么用?C# RedisClient.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RedisClient的用法示例。


在下文中一共展示了RedisClient.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MyTestMethod3

        public void MyTestMethod3()
        {
            using(var mock = new MockConnector("localhost", 9999, "+OK\r\n", "+OK\r\n"))
            using(var redis = new RedisClient(mock))
            {
                Assert.True(redis.Set("key", "value"));
                Assert.Equal("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n", mock.GetMessage());

                Assert.True(redis.Set("key", "value"));
                Assert.Equal("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n", mock.GetMessage());
            }
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:12,代码来源:RedisStreamTests.cs

示例2: Save

 public void Save(EngineInfo info)
 {
     var client = new RedisClient();
     var key = new EngineKeys ().GetInfoKey (info.Id);
     var json = info.ToJson ();
     client.Set(key, json);
 }
开发者ID:CompulsiveCoder,项目名称:TileSim,代码行数:7,代码来源:EngineInfoSaver.cs

示例3: ValidateTransfer

        public string ValidateTransfer(string sourceAppId, string userId, string transferId, string transferToken)
        {
            var red = new RedisClient<string>();
            var result = red.Get("transfertoken:" + transferId);
            if (!string.IsNullOrEmpty(result))
            {
                var redResult = red.Del("transfertoken:" + transferId);

                var redapp = new RedisClient<AppRegistry>();
                redapp.Select(1);
                var app = redapp.Get(HttpContext.Current.Items["AppId"] as string);

                var str = "UserId=" + userId + "&TransferId=" + transferId + "&Salt=" + app.AppSecret ;
                str = Hash.GetHash(str, Hash.HashType.SHA256);

                if (transferToken != str)
                {
                    throw new FaultException<UnauthorizedAccessException>(new UnauthorizedAccessException("token yanlış"));
                }

                string sessionguid = Guid.NewGuid().ToString();
                var redis = new RedisClient<Common.SessionRegistry>();
                var appId = HttpContext.Current.Items["AppId"] as string;
                redis.Set(sessionguid, new SessionRegistry() { SessionCookie = sessionguid, AppId = appId, UserId = userId });
                return sessionguid;
            }
            return null;
        }
开发者ID:endulus,项目名称:oynamalar,代码行数:28,代码来源:AuthService.svc.cs

示例4: 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();
     }
 }
开发者ID:swatabc,项目名称:ServiceStack.Redis,代码行数:9,代码来源:SslTests.cs

示例5: GetTest

 public void GetTest()
 {
     using (IRedisClient client = new RedisClient("localhost", ReidsDefaultTcpPort, 12))
     {
         Assert.IsTrue(client.Set("TestName2", "TestValue2"));
         Assert.AreEqual(client.Get("TestName2"), "TestValue2");
         Assert.IsTrue(client.Connected);
     }
 }
开发者ID:gnllk,项目名称:RedisClient,代码行数:9,代码来源:RedisClientTest.cs

示例6: 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();
     }
 }
开发者ID:swatabc,项目名称:ServiceStack.Redis,代码行数:10,代码来源:SslTests.cs

示例7: Save

        public void Save(Person person)
        {
            var client = new RedisClient();
            var key = new PeopleKeys ().GetPersonKey (person.Id);
            var json = person.ToJson ();
            client.Set(key, json);

            var idManager = new DataIdManager ();
            idManager.Add (person);
        }
开发者ID:CompulsiveCoder,项目名称:TileSim,代码行数:10,代码来源:PersonSaver.cs

示例8: Del_key

        public void Del_key()
        {
            using (var rcClient = new RedisClient(ip, port))
            {
                rcClient.Set("Set_Get_key", "Set_Get_key");
                var reply = rcClient.DelKey("Set_Get_key");

                Assert.AreEqual(reply, 1);
            }
        }
开发者ID:suifei,项目名称:HRedis,代码行数:10,代码来源:StringTests.cs

示例9: Save

        public void Save(Tile tile, Building[] buildings)
        {
            var client = new RedisClient();
            var json = ArrayToJson (buildings);
            var key = new BuildingKeys ().GetBuildingsKey (tile.Id);
            client.Set(key, json);

            //var idManager = new DataIdManager ();
            //idManager.Add (tile);
        }
开发者ID:CompulsiveCoder,项目名称:TileSim,代码行数:10,代码来源:BuildingSaver.cs

示例10: Save

        public void Save(BaseInstruction instruction)
        {
            var client = new RedisClient();
            var key = new InstructionKeys ().GetKey (instruction.Id);

            var json = instruction.ToJson ();
            client.Set(key, json);

            var idManager = new InstructionIdManager ();
            idManager.Add (instruction);
        }
开发者ID:CompulsiveCoder,项目名称:TileSim,代码行数:11,代码来源:InstructionSaver.cs

示例11: Set_Get_key

        public void Set_Get_key()
        {
            var key = "Set_Get_key";
            using (var rcClient = new RedisClient(ip, port))
            {
                rcClient.Set(key, key);

                var info2 = rcClient.Get(key);

                Assert.AreEqual(info2.ToString(), key);
            }
        }
开发者ID:suifei,项目名称:HRedis,代码行数:12,代码来源:StringTests.cs

示例12: Continuation_Set_Get_ByDifferentClient

 public void Continuation_Set_Get_ByDifferentClient()
 {
     for (int i = 0; i < 1000; i++)
     {
         using (var rcClient = new RedisClient(ip, port))
         {
             rcClient.Set("Continuation_Set_Get_ByDifferentClient" + i, i.ToString(), 10);
             rcClient.Get("Continuation_Set_Get_ByDifferentClient" + i);
             rcClient.Send(RedisCommand.INFO);
         }
     }
 }
开发者ID:suifei,项目名称:HRedis,代码行数:12,代码来源:PerformanceTests.cs

示例13: SetUTF8Test

        public void SetUTF8Test()
        {
            using (var mock = new FakeRedisSocket("+OK\r\n", "+OK\r\n"))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                Assert.AreEqual("OK", redis.Set("test", "é"));
                Assert.AreEqual("*3\r\n$3\r\nSET\r\n$4\r\ntest\r\n$2\r\né\r\n", mock.GetMessage());

                Assert.AreEqual("OK", redis.SetAsync("test", "é").Result);
                Assert.AreEqual("*3\r\n$3\r\nSET\r\n$4\r\ntest\r\n$2\r\né\r\n", mock.GetMessage());
            }
        }
开发者ID:DTBruce,项目名称:csredis,代码行数:12,代码来源:RegressionTests.cs

示例14: Search_Test

		public void Search_Test()
		{
			using (var client = new RedisClient(TestConfig.SingleHost))
			{
				const string cacheKey = "urn+metadata:All:SearchProProfiles?SwanShinichi Osawa /0/8,0,0,0";
				const long value = 1L;
				client.Set(cacheKey, value);
				var result = client.Get<long>(cacheKey);

				Assert.That(result, Is.EqualTo(value));
			}
		}
开发者ID:nekitozzz,项目名称:ServiceStack.Redis,代码行数:12,代码来源:AdhocClientTests.cs

示例15: Logon

 public string Logon(string username, string password, string mode)
 {
     if (username == "mucit" && password == "endulus")
     {
         string sessionguid = Guid.NewGuid().ToString();
         var redis = new RedisClient<Common.SessionRegistry>();
         var appId = HttpContext.Current.Items["AppId"] as string;
         redis.Set(sessionguid, new SessionRegistry() {SessionCookie=sessionguid, AppId=appId, UserId=username});
         return sessionguid;
     }
     else throw new FaultException<UnauthorizedAccessException>(new UnauthorizedAccessException("şifre yanlış"));
 }
开发者ID:endulus,项目名称:oynamalar,代码行数:12,代码来源:AuthService.svc.cs


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