public void Set(GetImageRequest request, ImageResponse imageResponse)
        {
            var cacheEntryOptions = new MemoryCacheEntryOptions()
                                    .SetSize(imageResponse.Content.Length / 1024)
                                    .SetSlidingExpiration(TimeSpan.FromHours(_appSettings.CacheExpiryInHours));

            _memoryCache.Set(request, imageResponse, cacheEntryOptions);
        }
        public async Task <ImageResponse> GetProcessedImage(GetImageRequest request, CancellationToken cancellationToken)
        {
            var image = await _imageService.LoadImage($"{_appSettings.ProductImagesPath}{request.FileName}", cancellationToken);

            _imageService.ConstrainSize(image, request);
            _imageService.SetBackgroundColor(image, request);
            _imageService.SetWaterMark(image, request);

            var(bytes, contentType) = await _imageSavingStrategy.SaveImage(image, request.ImageFileType, cancellationToken);

            return(ImageResponse.GetResponse(ResponseType.Ok, bytes, contentType));
        }
 public bool TryGetValue(GetImageRequest request, out ImageResponse imageResponse)
 {
     return(_memoryCache.TryGetValue(request, out imageResponse));
 }