diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index 5b67999a..6fe50f38 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -96,13 +96,19 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.NotFound)] public async Task GetPoetByUrl(string url) { - RServiceResult res = - await _ganjoorService.GetPoetByUrl(url); - if (!string.IsNullOrEmpty(res.ExceptionString)) - return BadRequest(res.ExceptionString); - if (res.Result == null) - return NotFound(); - return Ok(res.Result); + var cacheKey = $"poet/byurl/{url}"; + if (!_memoryCache.TryGetValue(cacheKey, out GanjoorPoetCompleteViewModel poet)) + { + RServiceResult res = + await _ganjoorService.GetPoetByUrl(url); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + if (res.Result == null) + return NotFound(); + poet = res.Result; + _memoryCache.Set(cacheKey, poet); + } + return Ok(poet); } ///