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


C# ConfigurationOptions.ToString方法代码示例

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


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

示例1: Connect

        public static ConnectionMultiplexer Connect(RedisConfiguration configuration)
        {

            string connectionString = configuration.ConnectionString;
            if (string.IsNullOrWhiteSpace(configuration.ConnectionString))
            {
                Func<RedisConfiguration, string> createConfigurationOptions = (config) =>
                {
                    var configurationOptions = new ConfigurationOptions()
                    {
                        AllowAdmin = config.AllowAdmin,
                        ConnectTimeout = config.ConnectionTimeout,
                        Password = config.Password,
                        Ssl = config.IsSsl,
                        SslHost = config.SslHost,
                        ConnectRetry = 10,
                        AbortOnConnectFail = false
                    };
                    foreach (var endpoint in configuration.Endpoints)
                    {
                        configurationOptions.EndPoints.Add(endpoint.Host, endpoint.Port);
                    }

                    return configurationOptions.ToString();
                };
                connectionString = createConfigurationOptions(configuration);
            }
            ConnectionMultiplexer connection;
            lock (connectLock)
            {
                if (!connections.TryGetValue(connectionString, out connection))
                {
                    var builder = new StringBuilder();
                    using (var log = new StringWriter(builder, CultureInfo.InvariantCulture))
                    {
                        connection = ConnectionMultiplexer.Connect(connectionString, log);
                    }

                    connection.ConnectionFailed += (sender, args) =>
                    {
                        connections.Remove(connectionString);
                    };

                    if (!connection.IsConnected)
                    {
                        throw new InvalidOperationException("Connection failed.\n" + builder.ToString());
                    }

                    connection.PreserveAsyncOrder = false;
                    connections.Add(connectionString, connection);
                }
            }

            return connection;
        }
开发者ID:a526757124,项目名称:OTGFramework,代码行数:55,代码来源:RedisConnectionPool.cs

示例2: Main

        static void Main(string[] args)
        {
            var opts = new ConfigurationOptions();
            opts.ClientName = "Test-Clinet";
            opts.KeepAlive = 180;
            opts.Password = "123456";
            Console.WriteLine(opts.ToString());

            var db = _redisClient.GetDatabase();
            db.StringSet("Key", Guid.NewGuid().ToString());
            var value = db.StringGet("Key");
            Console.WriteLine(value);

            Console.WriteLine("\nPress Any Key To Exit...");
            Console.ReadLine();
        }
开发者ID:yuanrui,项目名称:Examples,代码行数:16,代码来源:Program.cs

示例3: GetRedisConnectionString

        public static string GetRedisConnectionString()
        {
            var settings = ParseVCAP();
            ConfigurationOptions config = new ConfigurationOptions
            {
                EndPoints =
                    {
                        { settings.RedisHost, int.Parse(settings.RedisPort)}
                    },
                CommandMap = CommandMap.Create(new HashSet<string>
                { // EXCLUDE a few commands
                    /*"INFO", "CONFIG", "CLUSTER",
                    "PING", "ECHO", "CLIENT"*/
                }, available: false),
                KeepAlive = 180,
                DefaultVersion = new Version(2, 8, 8),
                Password = settings.RedisPassword
            };

            return config.ToString();
        }
开发者ID:Altoros,项目名称:Altoros-PCF.Net,代码行数:21,代码来源:Startup.cs

示例4: SingletonRedisConnection

        //public SingletonRedisConnection()
        //{
        //    this.redisConnectionString = "";
        //}

        public SingletonRedisConnection(ConfigurationOptions options)
        {
            this.redisConnectionString = options.ToString();
        }
开发者ID:S-origin,项目名称:Tam.Framework,代码行数:9,代码来源:SingletonRedisConnection.cs


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