 This will make it easier for other users to find. You can also add tags to further improve searchability. I'll add this to the RHEL product.
Thanks, when I click to start a new discussion, I see no option to tag it against a product. Also, clicking on the 'Formatting Help' here results in a popup with the entire screen shadowed out (hard to read, using Chrome 28).
Thanks Daryl. I've noticed the "Formatting Help" issue too, so we'll get that resolved as soon as we can.
Could you possibly mail me a screenshot of how your interface looks on the "new discussion" page? You should be seeing an option to add both product and tags.JLN Environmental/Energy: China’s Spending on Renewable Energy May Total 1.8 Trillion Yuan; New EPA chief takes on critics of U.S. agency's policies; Carbon neutral growth for aviation – At what price?
Bloomberg New Energy Finance and UN to open carbon market offices in Bogota and Manila from the blog Responding to Climate Change. From the political realm, Republicans May Make Keystone a Budget Issue, Ryan Says.
British coal-fired power producer Drax posted a sharp decline in half-year profit on Tuesday, blaming high costs of meeting carbon emissions reduction for its earnings slump.
House Budget Committee Chairman Paul Ryan said the Keystone XL oil pipeline may be part of budget negotiations as his Republican colleagues criticized President Barack Obama for saying the project wouldn’t create many jobs.
Change may be looming for the U.S. biofuel mandate as a powerful Congressional panel sets its sights on the program and pressure mounts for the Obama administration to relieve fuel market problems created by rising renewable fuel targets.
Delivering her first speech as the top U.S. environmental steward, Gina McCarthy on Tuesday pre-empted a frequent mantra of critics of the Environmental Protection Agency – that the agency’s regulations disrupt the economy and cost jobs.
JPMorgan Chase & Co. (JPM) will pay $410 million to settle U.S. Federal Energy Regulatory Commission allegations that the bank manipulated power markets, enriching itself at the expense of consumers in California and the Midwest from 2010 to 2012.
Can anyone really predict what the world’s energy market will look like in 2040? Many certainly try – including companies and governments – but they don’t deserve to be taken too seriously and certainly shouldn’t be the basis for decision-making.
Carbon neutral growth for aviation – At what price?
Ever since the Kyoto Protocol in 1997 assigned to the International Civil Aviation Organization (ICAO) responsibility for managing greenhouse gas emissions from international aviation, progress in agreeing targets for the sector has been lamentably slow. Only recently has ICAO started to address the issue seriously, partly stimulated by the European Union’s unilateral decision to include a portion of these emissions within the EU Emissions Trading System.
The UN plans to open two new offices aimed at boosting the world’s flagging carbon markets by promoting trading in Latin America and South East Asia.
Lantmannen Agroetanol AB, a Swedish ethanol producer, criticized changes by Platts to the way the publisher will assess prices in Europe’s biofuel market.
China has started importing natural gas from Myanmar, a milestone as the world’s largest energy consumer expands its strategic access to energy resources across the Indian Ocean.
When it comes to natural resources in Africa, coverage tends to focus on the problematic (see Rio in Mozambique), the awkward relationships (see China), the political risk (see Congo) and the collapse in labour relations (see South Africa).
A fund backed by the U.K.’s Green Investment Bank channeled 20 million pounds ($30.6 million) into an energy project in Northern Ireland that will turn wood into electricity and heat.
Could failure to plan for a power-hungry data center be thwarting your company’s growth? The bad news: Close to 60 percent of IT decision makers say the state of their data center is “fair, serious or urgent,” and at the brink of running out of capacity in 2014, according to a report by UBM Tech and InformationWeek. Twenty-two percent of 100 executives said they regularly track energy usage in their data centers. However, in the online survey “The State of Data Center Evolution,” 42 percent never or seldom track energy efficiency.
The New York Stock Exchange (NYSE) has become the latest global exchange to sign up to a UN-backed initiative designed to promote the adoption of more demanding sustainability reporting rules for listed companies.
South Africa will look to the bond markets, banks and increasing customer revenue to finance the 700 billion rand ($71 billion) needed to meet the country’s growing demand for water, the Department of Water Affairs said.
<reponame>HelpMyStreet/front-end
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using HelpMyStreet.Cache;
using HelpMyStreet.Cache.Models;
using HelpMyStreet.Utils.Extensions;
using HelpMyStreet.Utils.Models;
using HelpMyStreetFE.Repositories;
using Microsoft.Extensions.Logging;
using Polly;
using Polly.Contrib.DuplicateRequestCollapser;


namespace HelpMyStreetFE.Services.Requests
{
    public class RequestCachingService : IRequestCachingService
    {
        private readonly IRequestHelpRepository _requestHelpRepository;
        private readonly ILogger<RequestCachingService> _logger;

        private static readonly IAsyncRequestCollapserPolicy _collapserPolicy = AsyncRequestCollapserPolicy.Create();

        private readonly IMemDistCache<RequestSummary> _memDistCache_RequestSummary;

        private const string CACHE_KEY_PREFIX = "request-caching-service";

        public RequestCachingService(IRequestHelpRepository requestHelpRepository, ILogger<RequestCachingService> logger, IMemDistCache<RequestSummary> memDistCache_RequestSummary)
        {
            _requestHelpRepository = requestHelpRepository?? throw new ArgumentNullException(nameof(requestHelpRepository));
            _logger = logger?? throw new ArgumentNullException(nameof(logger));
            _memDistCache_RequestSummary = memDistCache_RequestSummary?? throw new ArgumentNullException(nameof(memDistCache_RequestSummary));
        }

        /// <summary>
        /// Returns RequestSummaries from cache if possible, or from the repo
        /// </summary>
        /// <param name="requestIds">Requests to fetch</param>
        /// <param name="waitForData">If true, RequestSummaries will be fetched from the repo before returning.  If false, an empty List will be returned whilst any missing RequestSummaries are added to the cache in a separate thread</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<IEnumerable<RequestSummary>> GetRequestSummariesAsync(IEnumerable<int> requestIds, bool waitForData, CancellationToken cancellationToken)
        {
            var results = new List<RequestSummary>();
            var missingIds = new List<int>();
            var staleIds = new List<int>();

            foreach (int requestId in requestIds.Distinct())
            {
                var requestSummaryInWrapper = await GetRequestSummaryAsync(requestId, RefreshBehaviour.DontRefreshData, NotInCacheBehaviour.DontGetData, cancellationToken);
                if (requestSummaryInWrapper.Content == null)
                {
                    missingIds.Add(requestId);
                }
                else
                {
                    results.Add(requestSummaryInWrapper.Content);

                    if (requestSummaryInWrapper.IsFreshUntil < DateTime.UtcNow)
                    {
                        staleIds.Add(requestId);
                    }
                }
            }

            if (staleIds.Count > 0)
            {
#pragma warning disable CS4014
                Task.Factory.StartNew(async () => await RefreshCacheAsync(staleIds, cancellationToken));
#pragma warning restore CS4014
            }

            if (missingIds.Count > 0)
            {
                if (waitForData)
                {
                    results.AddRange(await RefreshCacheAsync(missingIds, cancellationToken));
                }
                else
                {
#pragma warning disable CS4014
                    Task.Factory.StartNew(async () => await RefreshCacheAsync(missingIds, cancellationToken));
#pragma warning restore CS4014
                    
                    return new List<RequestSummary>();
                }
            }

            return results;
        }

        /// <summary>
        /// Returns a RequestSummary, from cache if possible or from the repo if not
        /// </summary>
        /// <param name="requestId">Request to fetch</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<RequestSummary> GetRequestSummaryAsync(int requestId, CancellationToken cancellationToken)
        {
            // RefreshBehaviour.DontRefreshData avoids tsunami of calls to Request Service when loading a long page of requests
            // Refresh of stale RequestSummaries will be triggered via GetRequestSummariesAsync instead