Esempio n. 1
0
        public void Open(RedisConfig config)
        {
            var serializer = new NewtonsoftSerializer();
            var connectionString = config.GetRedisConfiguration();

            try
            {
                _client = new StackExchangeRedisCacheClient(serializer, connectionString);
            }
            catch (Exception)
            {
                _client = null;
            }
        }
Esempio n. 2
0
        public void Open(RedisConfig config)
        {
            var connectionString = config.GetRedisConfiguration();
            var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token;

            try
            {
                Task.Run(
                    () => _connection = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(connectionString)), cancellationToken).Wait(cancellationToken);
                _server = _connection.GetServer(config.Host, config.Port);
            }
            catch (Exception)
            {
                _connection = null;
            }
        }