Example #1
0
        public IDatabase GetCommand(bool master, RedisKey key)
        {
            var settings   = _serverSelector.Select(master ? MasterSettings : SlaveSettings, key);
            var connection = settings.GetConnection();

            return(connection.GetDatabase(settings.Db));
        }
Example #2
0
                    public int Add(int a, int b)
                    {
                        var servers = _discovery.GetInstances <T>();                                      //服务发现
                        var server  = _selector.Select(servers);                                          //负载均衡
                        var desc    = new RemoteProcedure(_version, typeof(ICalculator), _addMethodInfo); //rpc描述

                        return((int)_caller.Call(server, desc, new IProcedureParameter[]
                        {
                            new ProcedureParameter(nameof(a), a),
                            new ProcedureParameter(nameof(b), b)
                        }));  //rpc调用
                    }
Example #3
0
 public RedisSettings GetSettings(string key)
 {
     return(serverSelector.Select(Settings, key));
 }