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


C# Redis.ConfigurationOptions类代码示例

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


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

示例1: UseRedisStorage

 public static IGlobalConfiguration<RedisStorage> UseRedisStorage(this IGlobalConfiguration configuration, ConfigurationOptions Options, int db, string Prefix)
 {
     if (configuration == null) throw new ArgumentNullException("configuration");
     if (Options == null) throw new ArgumentNullException("Options");
     var storage = new RedisStorage(Options, db, Prefix);
     return configuration.UseStorage(storage);
 }
开发者ID:okusnadi,项目名称:Hangfire.Redis.StackExchange,代码行数:7,代码来源:RedisStorageExtensions.cs

示例2: GetRedisConnection

        private static ConnectionMultiplexer GetRedisConnection()
        {
            ConnectionMultiplexer connection;
            string isLocal = ConfigurationManager.AppSettings["IsLocal"];

            if (isLocal == "1")
            {
                connection = ConnectionMultiplexer.Connect(ConfigurationManager.AppSettings["RedisServer"]);
            }
            else
            {
                var options = new ConfigurationOptions();

                options.EndPoints.Add(ConfigurationManager.AppSettings["RedisKeyDns"], 6380);
                options.Ssl = true;

                options.Password = ConfigurationManager.AppSettings["RedisPassword"];
                options.AllowAdmin = true;

                // necessary?
                options.KeepAlive = 30;
                options.ConnectTimeout = 15000;
                options.SyncTimeout = 15000;

                connection = ConnectionMultiplexer.Connect(options);
            }

            return connection;
        }
开发者ID:togglebrain,项目名称:stock-analytics,代码行数:29,代码来源:Program.cs

示例3: WatcherManager

        public WatcherManager(IEnumerable<WatchGroup> groups)
        {
            var groupList = groups.ToList();
            var config = new ConfigurationOptions()
            {
                AllowAdmin = true,
            };

            foreach (var group in groupList)
            {
                config.EndPoints.Add(group.Master.EndPoint);
            }

            muxerInstance = ConnectionMultiplexer.Connect(config);
            muxerInstance.ConnectionRestored += MuxerInstanceOnConnectionRestored;

            foreach (var group in groupList)
            {
                var server = muxerInstance.GetServer(group.Master.EndPoint);
                var epStr = server.EndPoint.ToString();

                group.Master.Server = server;
                group.Master.OnPing(TimeSpan.Zero);

                Program.zkAdaptor.Identity(group.Master.EndPoint.ToString());
                this.groups.Add(epStr, group);
                redisInstancesDict.Add(epStr, group.Master);
            }
        }
开发者ID:fingerpasswang,项目名称:Phial.Fantasy,代码行数:29,代码来源:WatcherManager.cs

示例4: CreateRedisCaches

		private static IList<RedisConnection> CreateRedisCaches(ICollection<RedisLockEndPoint> redisEndPoints)
		{
			var caches = new List<RedisConnection>(redisEndPoints.Count);

			foreach (var endPoint in redisEndPoints)
			{
                var configuration = new ConfigurationOptions
                {
                    AbortOnConnectFail = false,
                    ConnectTimeout = endPoint.ConnectionTimeout ?? DefaultConnectionTimeout,
                    Ssl = endPoint.Ssl,
                    Password = endPoint.Password,
				};

				configuration.EndPoints.Add(endPoint.EndPoint);

				caches.Add(new RedisConnection
				{
					ConnectionMultiplexer = ConnectionMultiplexer.Connect(configuration),
					RedisDatabase = endPoint.RedisDatabase ?? DefaultRedisDatabase,
					RedisKeyFormat = string.IsNullOrEmpty(endPoint.RedisKeyFormat) ? RedisLock.DefaultRedisKeyFormat : endPoint.RedisKeyFormat
				});
			}

			return caches;
		}
开发者ID:robzhu,项目名称:RedLock.net,代码行数:26,代码来源:RedisLockFactory.cs

示例5: MainForm

        public MainForm()
        {
            InitializeComponent();
            var options = new ConfigurationOptions
            {
                ConnectTimeout = 5000,
                SyncTimeout = 2000,
                KeepAlive = 60,
                EndPoints =
                {
                    {Settings.Default.RedisHost, Settings.Default.RedisPort}
                }
            };

            _redis = ConnectionMultiplexer.Connect(options);
            var retries = 0;
            while (!_redis.IsConnected)
            {
                var config = _redis.Configuration;
                _redis.Dispose();
                if (retries > 10)
                {
                    MessageBox.Show(string.Format("Could not connect to the Redis server with configuration: {0}",
                        config));
                    Application.Exit();
                }

                _redis = ConnectionMultiplexer.Connect(options, Console.Out);
                retries++;

            }
            _red = new LightControlSet(button_RedOn, button_RedOff, button_RedFlash, textBox_RedOnDuty, textBox_RedOffDuty, textBox_RedOffset, textBox_RedPower, button_RedApply);
            _green = new LightControlSet(button_GreenOn, button_GreenOff, button_GreenFlash, textBox_GreenOnDuty, textBox_GreenOffDuty, textBox_GreenOffset, textBox_GreenPower, button_GreenApply);
            _blueYellow = new LightControlSet(button_BlueOn, button_BlueOff, button_BlueFlash, textBox_BlueOnDuty, textBox_BlueOffDuty, textBox_BlueOffset, textBox_BluePower, button_BlueApply);
        }
开发者ID:rhysparry,项目名称:HIDVIWINCS,代码行数:35,代码来源:Form1.cs

示例6: RedisUtils

		static RedisUtils()
		{
			connection = new Lazy<ConnectionMultiplexer>(() =>
				{
					ExceptionDispatchInfo lastError = null;
					ConfigurationOptions options = new ConfigurationOptions();
					options.EndPoints.Add(GetHostAndPort());
					options.AllowAdmin = true;
					for (int i = 0; i < 5; i++)
					{
						try
						{
							var cnn = ConnectionMultiplexer.Connect(options);
							if (cnn.IsConnected)
								return cnn;
						}
						catch (Exception ex)
						{
							lastError = ExceptionDispatchInfo.Capture(ex);
							Console.WriteLine(ex.Message);
							Thread.Sleep(10);
						}
					}
					lastError.Throw();
					return null;
				}
			);
		}
开发者ID:xyting,项目名称:Hangfire.Redis.StackExchange,代码行数:28,代码来源:RedisUtils.cs

示例7: Can_start_slave

        public async Task Can_start_slave()
        {

            using (var redis = new Redis())
            using (var redis2 = new Redis())
            {
                ////Arrange
                // configure slave
                var config = new ConfigurationOptions { AllowAdmin = true };
                config.EndPoints.Add(redis.Endpoint);
                config.EndPoints.Add(redis2.Endpoint);
                using (var client = ConnectionMultiplexer.Connect(config))
                    await client.GetServer(redis.Endpoint).SlaveOfAsync(redis2.Endpoint);

                // new single-node client
                string actualValue;
                using (var client = ConnectionMultiplexer.Connect(redis2.Endpoint.ToString()))
                {

                    await client.GetDatabase().StringSetAsync("key", "value");

                    ////Act
                    actualValue = await client.GetDatabase().StringGetAsync("key");
                }

                ////Assert
                Assert.That(actualValue, Is.EqualTo("value"));
            }
        }
开发者ID:AtwooTM,项目名称:redis-inside,代码行数:29,代码来源:RedisTests.cs

示例8: RedisCacheConfig

        static RedisCacheConfig()
        {
            string isLocal = WebConfigReader.Read("IsLocal");

            if (isLocal == "1")
            {
                connection = ConnectionMultiplexer.Connect(WebConfigReader.Read("RedisServer"));
            }
            else
            {
                var options = new ConfigurationOptions();

                options.EndPoints.Add(WebConfigReader.Read("RedisKeyDns"), 6380);
                options.Ssl = true;

                options.Password = WebConfigReader.Read("RedisPassword");
                options.AllowAdmin = true;

                // necessary?
                options.KeepAlive = 30;
                options.ConnectTimeout = 15000;
                options.SyncTimeout = 15000;

                connection = ConnectionMultiplexer.Connect(options);
            }
        }
开发者ID:togglebrain,项目名称:stock-analytics,代码行数:26,代码来源:RedisCacheConfig.cs

示例9: RedisManager

        public RedisManager()
        {
            var configurationOptions = new ConfigurationOptions {Password = "be61827946a5d7a6b7333875104d4a26"};
            configurationOptions.EndPoints.Add(HostAndPort);

            _redisConn = ConnectionMultiplexer.Connect(configurationOptions);
        }
开发者ID:GabrielMCardozo,项目名称:Visivel2,代码行数:7,代码来源:RedisManager.cs

示例10: RedisTest

 protected RedisTest()
 {
     var config = new ConfigurationOptions() { AllowAdmin = true };
     config.EndPoints.Add(testHost, testPort);
     Multiplexer = ConnectionMultiplexer.Connect(config);
     Redis = GetFlushedRedis();
 }
开发者ID:TheCloudlessSky,项目名称:Harbour.RedisTempData,代码行数:7,代码来源:RedisTest.cs

示例11: RedisCommon

 public RedisCommon(string host="127.0.0.1", int port = 6379, string password = "") {
     options = new ConfigurationOptions {
         AllowAdmin = true,
         EndPoints = {new IPEndPoint(IPAddress.Parse(host), port)},
         Password = password
     };
 }
开发者ID:kangwl,项目名称:KANG.Frame,代码行数:7,代码来源:RedisCommon.cs

示例12: RedisAdaptor

        public RedisAdaptor(List<EndPoint> endPoints)
        {
            var config = new ConfigurationOptions()
            {
                AllowAdmin = true,
            };

            foreach (var endPoint in endPoints)
            {
                config.EndPoints.Add(endPoint);
            }

            muxerInstance = ConnectionMultiplexer.Connect(config);

            Handle = muxerInstance.GetDatabase();

            var script = Load("update_multikeys_multifields.lua");

            //todo a hack way .. to be changed later
            foreach (var endPoint in muxerInstance.GetEndPoints())
            {
                var server = muxerInstance.GetServer(endPoint);

                updateScriptSha = server.ScriptLoad(script);
            }

            Handle.StringSet("test", "111");
        }
开发者ID:fingerpasswang,项目名称:Phial,代码行数:28,代码来源:RedisAdaptor.cs

示例13: Connect

        public static void Connect()
        {
            ConfigurationOptions options = new ConfigurationOptions();
            options.EndPoints.Add("localhost:6379");

            Connection = ConnectionMultiplexer.Connect(options);
        }
开发者ID:angelrubenyui,项目名称:KnowTechDDD,代码行数:7,代码来源:RedisConnectionFactory.cs

示例14: Init

        public static void Init(string sHost, int iPort, string sPassword)
        {
            CacheDatabase._Host = sHost;
            CacheDatabase._Port = iPort;
            CacheDatabase._Password = sPassword;
            if (CacheDatabase._Password.Length > 0)
            {
                CacheDatabase._AuthRequired = true;
            }
            else
            {
                CacheDatabase._AuthRequired = false;
            }

            _oConectionOptions = new ConfigurationOptions();
            if (CacheDatabase._AuthRequired)
            {
                CacheDatabase._oConectionOptions.Password = CacheDatabase._Password;
            }

            CacheDatabase._oConectionOptions.EndPoints.Add(CacheDatabase._Host + ":" + CacheDatabase._Port.ToString());
            CacheDatabase._oCacheConnection = ConnectionMultiplexer.Connect(CacheDatabase._oConectionOptions);
            CacheDatabase._oCommand = CacheDatabase._oCacheConnection.GetDatabase();
            //Check to make sure the Key Exists and if not then set it to 0
            if (!_oCommand.KeyExists(CacheDatabase._ObjectCounterKeyName))
            {
                CacheDatabase._oCommand.StringSet(CacheDatabase._ObjectCounterKeyName, 0);
            }
        }
开发者ID:jordanburnam,项目名称:SpotifyChangeControl,代码行数:29,代码来源:CacheDatabase.cs

示例15: RedisCache

 /// <summary>
 /// Initializes a new instance of the <see cref="RedisCache"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public RedisCache(ConfigurationOptions configuration)
 {
     if (RedisCache.connection == null)
     {
         try
         {
             connectionTask = ConnectionMultiplexer.ConnectAsync(configuration);
             connectionTask.ContinueWith(t =>
                 {
                     lock (syncronizationObject)
                     {
                         if (RedisCache.connection == null)
                             RedisCache.connection = t.Result;
                     }
                     this.cache = RedisCache.connection.GetDatabase();
                     Trace.TraceInformation("Redis Cache Provider connection complete - Correlation Id = {0}", Trace.CorrelationManager.ActivityId);
                 });
         }
         catch (AggregateException age)
         {
             age.Handle(e =>
             {
                 Trace.TraceError("Redis Cache Provider error - Correlation Id = {0}\n {1}\n {2}", Trace.CorrelationManager.ActivityId, e.Message, e.StackTrace);
                 return true;
             });
         }
         catch (Exception ex)
         {
             Trace.TraceError("Redis Cache Provider exception - Correlation Id = {0}\n {1}\n {2}", Trace.CorrelationManager.ActivityId, ex.Message, ex.StackTrace);
         }
     }
 }
开发者ID:vsthakur78,项目名称:AzureRedisCacheProvider,代码行数:36,代码来源:RedisCache.cs


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