Ejemplo n.º 1
0
        public async Task <IEnumerable <PhotoListDTO> > GetSharedWithUserPhotos()
        {
            IEnumerable <PhotoListDTO> photos = await _photosService.GetAllPhotosAsync();

            IEnumerable <SharedPhotosDTO> sharedPhotos = await _sharingService.GetSharedWithUserPhotosAsync();

            return(_sharingAggregator.Combine(sharedPhotos, photos));
        }
        public async Task <IEnumerable <PhotoListDTO> > GetAllPhotosAsync()
        {
            string cacheKey = "all_photos";

            if (!_cache.Has(cacheKey))
            {
                IEnumerable <PhotoListDTO> photoList = await _photosService.GetAllPhotosAsync();

                int expireTimeInMinutues             = 5;
                DistributedCacheEntryOptions options = new DistributedCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(expireTimeInMinutues));

                await _cache.SetAsync(cacheKey, photoList, options);
            }

            return(await _cache.GetAsync <IEnumerable <PhotoListDTO> >(cacheKey));
        }