Skip to content

Commit

Permalink
Fix error in user profile memory cache key.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkikos committed Oct 18, 2024
1 parent 64b26c5 commit 320bfa2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions aspnetcore/src/api/Controllers/ProfileDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ public async Task<IActionResult> Get()
return Ok(new ApiResponse(success: false, reason: Constants.ApiResponseReasons.PROFILE_NOT_FOUND));
}

// Cache key
string cacheKey = _userProfileService.GetCMemoryCacheKey_UserProfile(orcidId);

// Send cached response, if exists.
string cacheKey = _userProfileService.GetCMemoryCacheKey_UserProfile(orcidId);
if (_cache.TryGetValue(cacheKey, out ProfileEditorDataResponse cachedResponse))
{
return Ok(new ApiResponseProfileDataGet(success: true, reason: "", data: cachedResponse, fromCache: true));
Expand Down Expand Up @@ -106,8 +104,9 @@ public async Task<IActionResult> PatchMany([FromBody] ProfileEditorDataModificat
return Ok(new ApiResponse(success: false, reason: Constants.ApiResponseReasons.PROFILE_NOT_FOUND));
}

// Remove cached profile data response. Cache key is ORCID ID.
_cache.Remove(orcidId);
// Remove cached profile data response.
string cacheKey = _userProfileService.GetCMemoryCacheKey_UserProfile(orcidId);
_cache.Remove(cacheKey);

// Collect information about updated items to a response object, which will be sent in response.
ProfileEditorDataModificationResponse profileEditorDataModificationResponse = new();
Expand Down

0 comments on commit 320bfa2

Please sign in to comment.