public async Task <UserRepositoryDto> GetByLoginAsync(string login) { var cacheKey = GetCacheKeyFromLogin(login); var cached = await cache.GetAsync(cacheKey); if (cached != null) { return(BsonSerializer.Deserialize <UserRepositoryDto>(cached)); } var stored = await Collection.Find(user => user.Login == login).FirstOrDefaultAsync() ?? throw EntityNotFoundException.CreateUser(login); await cache.SetAsync(cacheKey, stored.ToBson(), cacheOptions.Value); return(stored); }