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