public override Task StartInternalAsync()
        {
            _host = new RedisHost(Token, Settings.Port, new RedisEngine(Settings.Port));
            _host.Start();

            return(Task.Run(() => WaitHandle.WaitAll(new WaitHandle[] { Token.WaitHandle })));
        }
示例#2
0
        public RedisConfigurator AddLocalServer()
        {
            var server = new RedisHost();

            Configuration.Hosts["local"] = server;
            return(this);
        }
示例#3
0
        public RedisConfigurator AddServer(string host, int port)
        {
            var server = new RedisHost(host, port);

            Configuration.Hosts[host] = server;
            return(this);
        }
示例#4
0
        public void RedisHost_ProcessStartsSuccessfully()
        {
            // Create a new Redis host, and ensure the process is running.
            RedisHost testHost = new RedisHost();

            testHost.Start();

            // Process running.
            Assert.IsTrue(testHost.Running);

            // Make sure the port we've requested is actually open.
            bool portOpen = false;

            try
            {
                using (TcpClient tcpClient = new TcpClient())
                {
                    tcpClient.Connect("localhost", InstanceParams.DefaultPortNumber);
                    portOpen = true;
                }
            }
            catch { }

            // Port can be spoken to.
            Assert.IsTrue(portOpen);
        }
示例#5
0
        public RedisConfigurator AddServer(string host)
        {
            var server = new RedisHost {
                Host = host
            };

            Configuration.Hosts[host] = server;
            return(this);
        }
        /// <summary>
        ///  Initializes a new instance of the <see cref="RedisDamageManager" /> class, which will allow us to interact with the cache.
        /// </summary>
        public RedisDamageManager()
        {
            // Create the Redis host, start it, and save the accessor.
            //  TODO: Connect to an existing one, if necessary.
            this.redisHost = new RedisHost();
            this.redisHost.Start();

            this.redisCache = this.redisHost.CreateAccessor();
        }
示例#7
0
        public void RedisHost_ProcessTerminatesSuccessfully()
        {
            // Create a new Redis host, and ensure the process is running.
            RedisHost testHost = new RedisHost();

            testHost.Start();

            // Dispose the host, and ensure that we've finished.
            testHost.Dispose();
            Assert.IsFalse(testHost.Running);
        }
示例#8
0
        public void RedisHost_ReturnsAccessorWhileRunning()
        {
            // Build the test host.
            RedisHost testHost = new RedisHost();

            testHost.Start();

            // Grab the accessor.
            var accessor = testHost.CreateAccessor();

            Assert.IsNotNull(accessor);
        }
示例#9
0
        public void RedisHost_ReturnsNullAccessorWhileNotRunning()
        {
            // Build the test host.
            RedisHost testHost = new RedisHost();

            testHost.Start();

            // Kill the process.
            testHost.Dispose();

            // Grab the accessor.
            var accessor = testHost.CreateAccessor();

            Assert.IsNull(accessor);
        }
        public ActionResult InstanceActions(string node)
        {
            var h = RedisHost.Get(node);

            if (h != null)
            {
                return(PartialView("Server.Actions", h));
            }
            var i = RedisInstance.Get(node);

            if (i != null)
            {
                return(PartialView("Instance.Actions", i));
            }
            return(JsonNotFound());
        }
        public static void AddRedis(this IServiceCollection services,
                                    string hostsInLine,
                                    string password,
                                    bool abortOnConnectFail = true,
                                    int syncTimeout         = 30)
        {
            var newRedisConfiguration = new RedisConfiguration()
            {
                AbortOnConnectFail = abortOnConnectFail,
                Password           = password,
                Ssl = true
            };

            if (!string.IsNullOrEmpty(hostsInLine))
            {
                var hosts = new List <RedisHost>();

                var splitted = hostsInLine.Split(' ');
                for (int i = 0; i < splitted.Length - 1; i += 2)
                {
                    var host = new RedisHost()
                    {
                        Host = splitted[i],
                        Port = Convert.ToInt32(splitted[i + 1])
                    };

                    hosts.Add(host);
                }

                newRedisConfiguration.Hosts = hosts.ToArray();
            }

            newRedisConfiguration.ConfigurationOptions.SyncTimeout = Convert.ToInt32(syncTimeout);

            services.AddStackExchangeRedisExtensions <NewtonsoftSerializer>(newRedisConfiguration);
            services.AddSingleton <IRedisCacheClient, RedisCacheClient>();
            services.AddSingleton <IRedisCacheConnectionPoolManager, RedisCacheConnectionPoolManager>();
        }
 public void CleanupDataAccessorTests()
 {
     this.redisInstance.Dispose();
     this.redisInstance = null;
 }
 public void InitializeDataAccessorTests()
 {
     this.redisInstance = new RedisHost();
     this.redisInstance.Start();
 }
示例#14
0
 public static void Config(string server, int port, string password)
 {
     RedisHost.Config(server, port, password);
 }