public void Start()
        {
            _log.Info("Getting disclaimers and lykke entities to cache");

            Task <IReadOnlyList <IDisclaimer> >  disclaimersTask = _disclaimerRepository.GetAllAsync();
            Task <IReadOnlyList <ILykkeEntity> > entitiesTask    = _lykkeEntityRepository.GetAsync();

            Task.WhenAll(disclaimersTask, entitiesTask).GetAwaiter().GetResult();

            _log.Info("Caching disclaimers");

            var tasks = new List <Task>();

            foreach (IEnumerable <IDisclaimer> disclaimers in disclaimersTask.Result.Batch(100))
            {
                tasks.AddRange(disclaimers.Select(x => _redisService.AddDisclaimerAsync(x)));
                Task.WhenAll(tasks).GetAwaiter().GetResult();
                tasks.Clear();
            }

            _log.Info("Caching disclaimers finished");

            _log.Info("Caching lykke entities");

            foreach (IEnumerable <ILykkeEntity> entities in entitiesTask.Result.Batch(100))
            {
                tasks.AddRange(entities.Select(x => _redisService.AddLykkeEntityAsync(x)));
                Task.WhenAll(tasks).GetAwaiter().GetResult();
                tasks.Clear();
            }

            _log.Info("Caching lykke entities finished");
        }
        public async Task <ILykkeEntity> GetLykkeEntityAsync(string id)
        {
            var data = await _database.HashGetAllAsync(GetLykkeEntityKey(id));

            if (data.Length != 0)
            {
                return(data.ToLykkeEntity());
            }

            var entity = await _lykkeEntityRepository.GetAsync(id);

            if (entity == null)
            {
                return(null);
            }

            await AddLykkeEntityAsync(entity);

            return(entity);
        }