Example #1
0
        private async Task <DataTrends> RetrieveDataTrendsFromCache(string babyId)
        {
            DataTrends latestTrends = null;
            var        cache        = await dataTrendsCache.Value;

            cache.TryGetValue(babyId, out latestTrends);
            return(latestTrends);
        }
Example #2
0
        private async Task SaveDataTrendsToCache(DataTrends latestTrends, string babyId)
        {
            var cache = await dataTrendsCache.Value;

            cache[babyId] = latestTrends;
            var cacheFile = await dataTrendsCacheFile.Value;
            await dataTrendsSemaphore.WaitAsync();

            try
            {
                await cacheFile.WriteJsonToFile(typeof(Dictionary <string, DataTrends>),
                                                cache);
            }
            finally
            {
                dataTrendsSemaphore.Release();
            }
        }
Example #3
0
 public IAsyncAction SaveDataTrends(DataTrends latestTrends, string babyId)
 {
     return(SaveDataTrendsToCache(latestTrends, babyId).AsAsyncAction());
 }