Skip to content

Commit

Permalink
Update cache after unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Jul 30, 2023
1 parent 02437d0 commit 8cd6786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions EmployeeUnlockDoor/Pages/UnlockDoor/UnlockDoor.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
AllowRefresh = false
});

CacheData.RemoveFromCache(StatePresented, _distributedCache);

return Redirect($"~/UnlockDoor/Unlocked");
}
}
9 changes: 9 additions & 0 deletions EmployeeUnlockDoor/Services/CacheData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ public static void AddToCache(string key, IDistributedCache cache, CacheData cac

return null;
}

public static void RemoveFromCache(string key, IDistributedCache cache)
{
var item = cache.GetString(key);
if (item != null)
{
cache.Remove(key);
}
}
}

0 comments on commit 8cd6786

Please sign in to comment.