當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。