<commit_before>using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using Engine.DataTypes;
using Engine.Drivers.Context;
using FSharpUtils.Newtonsoft;
using StackExchange.Redis;
using Newtonsoft.Json.Linq;
using System.Net;
using LanguageExt;
using Newtonsoft.Json;
using Tweek.ApiService.Addons;

namespace Tweek.Drivers.Redis
{
    public class RedisDriver : IContextDriver
    {
        private readonly ConnectionMultiplexer mRedisConnection;

        public string GetKey(Identity identity) => "identity_" + identity.Type + "_" + identity.Id;

        public RedisDriver(string connectionString)
        {
            var options = TranslateDnsToIP(ConfigurationOptions.Parse(connectionString));
            mRedisConnection = ConnectionMultiplexer.Connect(options);
        }

        private ConfigurationOptions TranslateDnsToIP(ConfigurationOptions configurationOptions)
        {
            var endpoints = configurationOptions.EndPoints
                .Select(endpoint => endpoint as DnsEndPoint)
                .SelectMany(endpoint =>
                    Dns.GetHostAddressesAsync(endpoint.Host).Result
                        .Select(ip => new IPEndPoint(ip, endpoint.Port))<commit_msg>Throw exception with readable message when redis connection string is not supplied<commit_after>using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using Engine.DataTypes;
using Engine.Drivers.Context;
using FSharpUtils.Newtonsoft;
using StackExchange.Redis;
using Newtonsoft.Json.Linq;
using System.Net;
using LanguageExt;
using Newtonsoft.Json;
using Tweek.ApiService.Addons;

namespace Tweek.Drivers.Redis
{
    public class RedisDriver : IContextDriver
    {
        private readonly ConnectionMultiplexer mRedisConnection;

        public string GetKey(Identity identity) => "identity_" + identity.Type + "_" + identity.Id;

        public RedisDriver(string connectionString)
        {
            if ((connectionString ?? "") == "")
            {
                throw new ArgumentException("Missing redis connection string", nameof(connectionString));
            }

            var options = TranslateDnsToIP(ConfigurationOptions.Parse(connectionString));
            mRedisConnection = ConnectionMultiplexer.Connect(options);
        }

        private ConfigurationOptions TranslateDnsToIP(ConfigurationOptions configurationOptions)
        {
            var endpoints = configurationOptions.EndPoints
                .Select(endpoint => endpoint as DnsEndPoint)
                .SelectMany(endpoint =>
                    Dns.GetHostAddressesAsync(endpoint.Host).Result
                        .Select(ip => new IPEndPoint(ip, endpoint.Port))
{'fraction_non_alphanumeric': 0.07793153678077203, 'fraction_numerical': 0.0, 'mean_word_length': 3.1122754491017965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5824383', 'n_tokens_mistral': 703, 'n_tokens_neox': 673, 'n_words': 155}