
Explanation:
void ClearCachedTeams() {
IDatabase cache = Connection.GetDatabase();
cache.KeyDelete("teamsList");
cache.KeyDelete("teamsSortedSet");
ViewBag.msg += "Team data removed from cache. ";
}
Box 1: IDatabase cache = connection.GetDatabase();
Connection refers to a previously configured ConnectionMultiplexer.
Box 2: Box 2: cache.KeyDelete("teams")
If you use StringSet you will set Teams to the value of Empty string and a future request to Teams will return an empty string and not null.
Reference:
https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-web-app-cache-aside-leaderboard#update-the-teamscontroller-to-read-from-the-cache-or-the-database