• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Redis.ConfigurationOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: RetrieveMultiplexer

        public static ConnectionMultiplexer RetrieveMultiplexer(ConfigurationOptions config)
        {
           if(_multiplexer != null) return _multiplexer;

            _multiplexer = ConnectionMultiplexer.Connect(config);
            return _multiplexer;
        }
开发者ID:subscriptionapp,项目名称:Client.Net,代码行数:7,代码来源:ConnectionHandler.cs


示例17: Get

        public HttpResponseMessage Get(string deviceId)
        {
            if (String.IsNullOrEmpty(deviceId))
                return new HttpResponseMessage(HttpStatusCode.NoContent);

            ConfigurationOptions configurationOptions = new ConfigurationOptions();
            configurationOptions.EndPoints.Add("<< add your Redis cache name here >>.redis.cache.windows.net");
            configurationOptions.Ssl = true;
            configurationOptions.Password = "<< Add Access Key Here >>";

            ConnectionMultiplexer connectionMultiplexer = ConnectionMultiplexer.Connect(configurationOptions);
            IDatabase commandQueue = connectionMultiplexer.GetDatabase();

            RedisValue redisValue = commandQueue.ListRightPop(deviceId);
            if (redisValue.HasValue)
                return new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK,
                    Content = new StringContent(redisValue.ToString()),
                };
            else
                return new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.NoContent,
                    Content = new StringContent(""),
                };
        }
开发者ID:HydAu,项目名称:IoTMasterClass,代码行数:27,代码来源:CommandController.cs


示例18: ConnectWithConfiguration

 private static ConnectionMultiplexer ConnectWithConfiguration()
 {
     ConnectionMultiplexer redisConnection;
         if (string.IsNullOrWhiteSpace(configuration.ConnectionString))
         {
             var options = new ConfigurationOptions
             {
                 ClientName = configuration.ApplicationName,
                 ConnectTimeout = configuration.ConnectionTimeoutInMilliSec,
                 SyncTimeout = configuration.OperationTimeoutInMilliSec,
                 ResolveDns = true,
                 AbortOnConnectFail = false // Important for shared usage
             };
             if (!string.IsNullOrWhiteSpace(configuration.AccessKey))
                 options.Password = configuration.AccessKey;
             if (configuration.RetryCount > 0)
                 options.ConnectRetry = configuration.RetryCount;
             if (configuration.UseSsl)
             {
                 options.Ssl = configuration.UseSsl;
                 options.SslHost = configuration.Host;
             }
             var hosts = configuration.Host.Split(new[] {SPLITTER}, StringSplitOptions.RemoveEmptyEntries);
             foreach (var host in hosts)
             {
                 options.EndPoints.Add(host);
             }
             redisConnection = ConnectionMultiplexer.Connect(options);
         }
         else
         {
             redisConnection = ConnectionMultiplexer.Connect(configuration.ConnectionString);
         }
         return redisConnection;
 }
开发者ID:njfife,项目名称:playground,代码行数:35,代码来源:RedisUnlockedStateStore.cs


示例19: SetUp

        public void SetUp()
        {
            var config = new ConfigurationOptions() { EndPoints = { { _host, _port } }, Password = _password, DefaultDatabase = _database, AllowAdmin = true };
            _state = SchedulerFunc.Create(config, "Test", _database);

            var server = _state.Connection.GetServer(_state.Connection.GetEndPoints().First());
            server.FlushDatabase(_state.Database);
        }
开发者ID:mng-au,项目名称:Abot.Redis.Scheduler,代码行数:8,代码来源:SchedulerTests.cs


示例20: RedisConnectionFactory

 public RedisConnectionFactory(ConnectionMultiplexer conn, ConfigurationOptions configuration, JsonSerializerSettings jsonSerializerSettings)
 {
     _configurationOptions = configuration;
     _jsonSerializerSettings = jsonSerializerSettings;
     _conn = conn;
     if (!_conn.IsConnected)
         _conn = ConnectionMultiplexer.Connect(_configurationOptions); //TO DO - add other config options
 }
开发者ID:NRedisApi,项目名称:NRedisApi,代码行数:8,代码来源:RedisConnectionFactory.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Redis.ConnectionMultiplexer类代码示例发布时间:2022-05-26
下一篇:
C# Profiling.MiniProfiler类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap