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


C# ConnectionMultiplexer.GetServer方法代码示例

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


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

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

示例2: WorkflowManagement

        internal WorkflowManagement(ConnectionMultiplexer mux, ITaskHandler taskHandler, WorkflowHandler workflowHandler, string identifier, IEnumerable<string> typesProcessed, ILua lua, EventHandler<Exception> exceptionHandler = null, Behaviours behaviours = Behaviours.All)
        {
            _taskHandler = taskHandler;

            _workflowHandler = workflowHandler;

            if (exceptionHandler != null)
            {
                ExceptionThrown += exceptionHandler;
            }

            _typesProcessed = typesProcessed;

            _db = mux.GetDatabase();

            _sub = mux.GetSubscriber();

            if (_typesProcessed == null || _typesProcessed.Count() == 0)
            {
                _sub.Subscribe("submittedTask", (c, v) =>
                {
                    ProcessNextTask();
                });
            }
            else
            {
                foreach(var t in _typesProcessed)
                {
                    _sub.Subscribe("submittedTask:" + t, (c, v) =>
                    {
                        ProcessNextTask(t);
                    });
                }
            }

            _sub.Subscribe("workflowFailed", (c, v) =>
            {
                ProcessNextFailedWorkflow();
            });

            _sub.Subscribe("workflowComplete", (c, v) =>
            {
                ProcessNextCompleteWorkflow();
            });

            _lua = lua;
            _lua.LoadScripts(_db, mux.GetServer("localhost:6379"));

            _identifier = identifier;

            if (behaviours.HasFlag(Behaviours.AutoRestart))
            {
                var resubmittedTasks = ResubmitTasks();

                foreach (var item in resubmittedTasks)
                {
                    Console.WriteLine("Resubmitted {0}", item);
                }
            }
        }
开发者ID:Timxuhj,项目名称:redis.workflow,代码行数:60,代码来源:WorkloadManagement.cs

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

示例4: FetchAllKeys

        private static IEnumerable<RedisKey> FetchAllKeys(ConnectionMultiplexer multiplexer, EndPoint endpoint)
        {
            var server = multiplexer.GetServer(endpoint);

            var allKeys = server.Keys()
                                .ToArray();

            return allKeys;
        }
开发者ID:NimbusAPI,项目名称:Nimbus,代码行数:9,代码来源:NamespaceCleanser.cs

示例5: TryGetServer

        internal static IServer TryGetServer(ConnectionMultiplexer muxer, bool checkConnected = true)
        {
            if (muxer != null)
            {
                var eps = muxer.GetEndPoints(true);
                foreach (var ep in eps)
                {
                    var server = muxer.GetServer(ep);
                    if (server.IsSlave) continue;
                    if (checkConnected && !server.IsConnected) continue;

                    // that'll do
                    return server;
                }
            }
            return null;
        }
开发者ID:kpitt,项目名称:RyuJIT-TailCallBug,代码行数:17,代码来源:AsyncRedisConnection.cs

示例6: GetServer

 internal static IServer GetServer(ConnectionMultiplexer conn)
 {
     return conn.GetServer(conn.GetEndPoints()[0]);
 }
开发者ID:dedalebeda,项目名称:StackExchange.Redis,代码行数:4,代码来源:Config.cs

示例7: Initialize

        private void Initialize()
        {
            var options = new ConfigurationOptions()
            {
                AllowAdmin = true,
                ConnectTimeout = 1000,
            };

            var endpoint = new DnsEndPoint(_redisConfig.Host, _redisConfig.Port, AddressFamily.InterNetwork);
            options.EndPoints.Add(endpoint);

            if (!string.IsNullOrEmpty(_redisConfig.Password))
                options.Password = _redisConfig.Password;

            try
            {
                // create the connection
                _connectionMultiplexer = ConnectionMultiplexer.ConnectAsync(options).Result;

                // access to database.
                _database = _connectionMultiplexer.GetDatabase(_redisConfig.DatabaseId);

                // get the configured server.
                _server = _connectionMultiplexer.GetServer(endpoint);

                // 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("Storage initialized: {0:l}:{1}, v{2:l}.", endpoint.Host, endpoint.Port, version);
            }
            catch (Exception e)
            {
                IsEnabled = false;
                _logger.Error(string.Format("Storage initialization failed: {0:l}:{1}.", endpoint.Host, endpoint.Port));
            }
        }
开发者ID:nuggetbram,项目名称:coinium-whrl,代码行数:38,代码来源:Redis.cs

示例8: RedisTests

 public RedisTests()
 {
     _multiplexer = new RedisDatabase().GetDatabase().Multiplexer;
     _server = _multiplexer.GetServer("localhost", 6379);
 }
开发者ID:andrewtsw,项目名称:Interesnee.BadBroker,代码行数:5,代码来源:RedisTests.cs

示例9: FlushDatabase

 /// <summary>
 /// Flushes the database that the connection belongs to.
 /// </summary>
 /// <param name="connection">
 /// The connection.
 /// </param>
 public void FlushDatabase(ConnectionMultiplexer connection)
 {
     EndPoint[] endPoints = connection.GetEndPoints();
     foreach (var endPoint in endPoints)
     {
         connection.GetServer(endPoint).FlushDatabase(this.Db);
     }
 }
开发者ID:JesseBuesking,项目名称:BB.Caching,代码行数:14,代码来源:SharedCache.cs

示例10: GetDashboardInfo

 /// <summary>
 /// Provide an alternate ConnectionMultiplexer to use for INFO command
 /// </summary>
 /// <param name="Connection"></param>
 /// <param name="title">Title to appear on the dashboard</param>
 /// <param name="key">Redis INFO key</param>
 /// <returns></returns>
 public DashboardMetric GetDashboardInfo(ConnectionMultiplexer Connection, string title, string key)
 {
     return GetDashboardInfo(Connection.GetServer(Connection.GetDatabase(Db).IdentifyEndpoint()), title, key);
 }
开发者ID:okusnadi,项目名称:Hangfire.Redis.StackExchange,代码行数:11,代码来源:RedisStorage.cs

示例11: ReconfigureConnection

        private void ReconfigureConnection(List<RedisInstanceBase> toConnect)
        {
            var config = ConfigurationOptions.Parse(muxerInstance.Configuration);

            foreach (var ins in toConnect)
            {
                config.EndPoints.Add(ins.EndPoint);
            }

            lock (muxerSyncLock)
            {
                muxerInstance.Dispose();
                muxerInstance = ConnectionMultiplexer.Connect(config);

                RefreshAll();

                muxerInstance.ConnectionRestored += MuxerInstanceOnConnectionRestored;
            }

            foreach (var ins in toConnect)
            {
                ins.Server = muxerInstance.GetServer(ins.EndPoint);
            }
        }
开发者ID:fingerpasswang,项目名称:Phial.Fantasy,代码行数:24,代码来源:WatcherManager.cs

示例12: Initialize

        private void Initialize()
        {
            var options = new ConfigurationOptions();
            var endpoint = new DnsEndPoint(Config.Host, Config.Port, AddressFamily.InterNetwork);
            options.EndPoints.Add(endpoint);
            options.AllowAdmin = true;
            if (!string.IsNullOrEmpty(Config.Password))
                options.Password = Config.Password;

            try
            {
                // create the connection
                _connectionMultiplexer = ConnectionMultiplexer.ConnectAsync(options).Result;

                // access to database.
                _database = _connectionMultiplexer.GetDatabase(Config.DatabaseId);

                // get the configured server.
                _server = _connectionMultiplexer.GetServer(endpoint);

                // check the version
                var info = _server.Info();
                Version version = null;
                foreach (var pair in info[0])
                {
                    if (pair.Key == "redis_version")
                    {
                        version = new Version(pair.Value);
                        if (version < _requiredMinimumVersion)
                            throw new Exception(string.Format("You are using redis version {0}, minimum required version is 2.6", version));

                        break;
                    }
                }

                Log.ForContext<Redis>().Information("Storage initialized: {0}, v{1}.", endpoint, version);
            }
            catch (Exception e)
            {
                IsEnabled = false;
                Log.ForContext<Redis>().Error(e, string.Format("Storage initialization failed: {0}", endpoint));
            }
        }
开发者ID:nuggetbram,项目名称:CoiniumServ,代码行数:43,代码来源:Redis.cs


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