예제 #1
0
        public void TestSslConnection()
        {
            var endPoint = new RedLockEndPoint
            {
                EndPoint = new DnsEndPoint("localhost", 6383),
                Ssl      = true
            };

            CheckSingleRedisLock(
                () => RedLockFactory.Create(new List <RedLockEndPoint> {
                endPoint
            }),
                true);
        }
        private static RedLockFactory CreateRedLockFactory()
        {
            var host = Configuration.GetValue <string>("Host");
            var port = Configuration.GetValue <int>("Port");

            var redisEndpoint = new RedLockEndPoint(new DnsEndPoint(host, port))
            {
                RedisDatabase  = 0,
                RedisKeyFormat = "MiniJobScheduler:{0}",
            };
            var listOfRedisEndpoints = new List <RedLockEndPoint> {
                redisEndpoint
            };
            var redLockFactory = RedLockFactory.Create(listOfRedisEndpoints);

            return(redLockFactory);
        }
예제 #3
0
        public static RedLockFactory Get(CacheSettings cacheSettings)
        {
            try
            {
                if (RedLockFactory == null)
                {
                    lock (Lock)
                    {
                        if (RedLockFactory == null)
                        {
                            var endpoint = new RedLockEndPoint
                            {
                                EndPoint          = new DnsEndPoint(cacheSettings.Host, cacheSettings.Port),
                                Password          = cacheSettings.Password,
                                Ssl               = cacheSettings.Ssl,
                                RedisDatabase     = cacheSettings.LockerDb,
                                SyncTimeout       = cacheSettings.TimeoutInMs,
                                ConnectionTimeout = cacheSettings.TimeoutInMs,
                            };

                            var hosts = new List <RedLockEndPoint> {
                                endpoint
                            };
                            RedLockFactory = RedLockFactory.Create(hosts);
                        }
                    }
                }
            }
            catch (Exception)
            {
                CloseConnection();
                throw;
            }

            return(RedLockFactory);
        }