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


C# RedisClient.Select方法代码示例

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


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

示例1: 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

示例2: Initialize

        private void Initialize()
        {
            try
            {
                // create the connection
                Client = new RedisClient(_config.Host, _config.Port)
                {
                    ReconnectAttempts = 3,
                    ReconnectTimeout = 200
                };

                // select the database
                Client.Select(_config.DatabaseId);

                // authenticate if needed.
                if (!string.IsNullOrEmpty(_config.Password))
                    Client.Auth(_config.Password);

                // check the version
                var version = GetVersion();
                if (version < _requiredMinimumVersion)
                    throw new Exception(string.Format("You are using redis version {0}, minimum required version is 2.6", version));

                _logger.Information("Redis storage initialized: {0:l}:{1}, v{2:l}.", _config.Host, _config.Port, version);
            }
            catch (Exception e)
            {
                _logger.Error("Redis storage initialization failed: {0:l}:{1} - {2:l}", _config.Host, _config.Port, e.Message);
            }
        }
开发者ID:carloslozano,项目名称:CoiniumServ,代码行数:30,代码来源:RedisProvider.cs

示例3: SelectTest

 public void SelectTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "+OK\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.True( redis.Select(2));
         Assert.Equal("*2\r\n$6\r\nSELECT\r\n$1\r\n2\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisConnectionTests.cs

示例4: Transfer

        public string Transfer(string targetAppId, string transferToken)
        {
            NameValueCollection nv = new NameValueCollection();
            nv["AppId"] = targetAppId;
            nv["Secret"] = Guid.NewGuid().ToString();
            nv["ExpireAt"] = DateTime.Now.AddMinutes(3).ToLongTimeString();

            var redis = new RedisClient<AppRegistry>();
            redis.Select(1);
            var app = redis.Get(targetAppId);

            string token = "AppId=" + targetAppId + "&UserId=" + HttpContext.Current.Items["UserId"]  + "&Secret=" + Guid.NewGuid().ToString() + "&ExpireAt=" + DateTime.Now.AddMinutes(3).ToLongTimeString();
            string transferId = Guid.NewGuid().ToString();
            string token2 = "UserId=" + HttpContext.Current.Items["UserId"] + "&TransferId=" + transferId + "&Salt=" + app.AppSecret;
            token2 = Common.Hash.GetHash(token2, Hash.HashType.SHA256);

            token = Common.Crypto.EncryptStringAES(token, app.AppSecret);

            var red = new RedisClient<string>();
            red.Set("transfertoken:" + transferId, token2);
            //red.ExpireAt("transfertoken:" + token, DateTime.Now.AddMinutes(1));

            return "tid=" + transferId + "&tkn=" + token2;
        }
开发者ID:endulus,项目名称:oynamalar,代码行数:24,代码来源:TransferService.svc.cs

示例5: SelectTest

 public void SelectTest()
 {
     using (IRedisClient client = new RedisClient("localhost", ReidsDefaultTcpPort, 12))
     {
         Assert.IsTrue(client.Set("TestName3", "TestValue3"));
         Assert.IsTrue(client.Select(13));
         Assert.AreNotEqual(client.Get("TestName3"), "TestValue3");
         Assert.IsTrue(client.Connected);
     }
 }
开发者ID:gnllk,项目名称:RedisClient,代码行数:10,代码来源:RedisClientTest.cs


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