예제 #1
0
        public async Task <IActionResult> GetCachedObject(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException($"Cannot be null or empty : {nameof(key)}");
            }
            try
            {
                var oneOfResponse = await _cachingService.GetCachedObject(key);

                return(oneOfResponse.Match <IActionResult>(
                           DataObject => new OkObjectResult(DataObject),
                           NotFoundCacheObject => new NotFoundObjectResult(NotFoundCacheObject)));
            }
            catch (CachingServiceException csex)
            {
                _logger.LogError($"Error {nameof(CachingServiceException)}", csex);
                return(StatusCode(500));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error {nameof(Exception)}", ex);
                return(StatusCode(500));
            }
        }