exam questions

Exam AZ-204 All Questions

View all questions & answers for the AZ-204 exam

Exam AZ-204 topic 5 question 4 discussion

Actual exam question from Microsoft's AZ-204
Question #: 4
Topic #: 5
[All AZ-204 Questions]

HOTSPOT -
A company is developing a gaming platform. Users can join teams to play online and see leaderboards that include player statistics. The solution includes an entity named Team.
You plan to implement an Azure Redis Cache instance to improve the efficiency of data operations for entities that rarely change.
You need to invalidate the cache when team data is changed.
How should you complete the code? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
agueda
Highly Voted 4 years, 1 month ago
Same question on AZ203 Answer is: IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("teams") https://www.examtopics.com/discussions/microsoft/view/12706-exam-az-203-topic-5-question-9-discussion/
upvoted 124 times
MonkeyKing1024
2 years, 1 month ago
https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-web-app-cache-aside-leaderboard#:~:text=void%20ClearCachedTeams()%0A%7B%0A%20%20%20%20IDatabase%20cache%20%3D%20Connection.GetDatabase()%3B%0A%20%20%20%20cache.KeyDelete(%22teamsList%22)%3B%0A%20%20%20%20cache.KeyDelete(%22teamsSortedSet%22)%3B%0A%20%20%20%20ViewBag.msg%20%2B%3D%20%22Team%20data%20removed%20from%20cache.%20%22%3B%0A%7D
upvoted 5 times
...
BrettusMaximus
3 years, 12 months ago
It is KeyDelete. 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
upvoted 20 times
coffecold
2 years, 6 months ago
Please see the GetFromList() in the tutorial. if (String.IsNullOrEmpty(serializedTeams)) then the DB will be read instead of the cache. Implementation with an empty string returned from cache if invalidated is no problem.
upvoted 2 times
...
...
...
hobob
Highly Voted 4 years, 1 month ago
Answer is incorrect (for the 2nd part). cache.KeyDelete() is the correct method for removing a key from the redis cache.
upvoted 33 times
Sukon_Desknot
3 years, 8 months ago
Kindly provide references if you believe your knowledge is better than exam topics', we are not in the faith business😁
upvoted 6 times
sas12321
3 years, 8 months ago
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
upvoted 24 times
...
...
...
fc61c73
Most Recent 5 months, 2 weeks ago
cache.KeyDelete("Team"); is the correct one
upvoted 1 times
...
4bd3116
8 months ago
The correct answer void ClearCachedTeams() { IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("Team"); ViewBag.msg += "Team data removed from cache."; }
upvoted 4 times
...
yusuf_eb
8 months, 2 weeks ago
1. IDatabase cache 2. cache.KeyDelete this method is also seen in the documentation: 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 crtlf + f 'ClearCachedTeams' and look for the method
upvoted 3 times
...
Stel0Papad4
10 months, 3 weeks ago
Ofcourse its KeyDelete() people. You need to clear the "Teams" data from the cache. Its not acceptable to just set the value of "Teams" data to an Empty String. If you do so, the "Teams" data will still be there, in the Redis Cache. You may avoid it vio code by saying if EmptyOrNull but its not what you wanna do. Just delete it from the cache and the Redis cache will automatically update it via the database.
upvoted 2 times
...
Firo
1 year, 8 months ago
Answer is: IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("teams"), https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-web-app-cache-aside-leaderboard
upvoted 5 times
...
Kluk_Kluk
2 years, 1 month ago
https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-web-app-cache-aside-leaderboard void ClearCachedTeams() { IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("teamsList"); cache.KeyDelete("teamsSortedSet"); ViewBag.msg += "Team data removed from cache. "; }
upvoted 3 times
...
NeelParghi
2 years, 2 months ago
KeyDelete Delete the key/value. Ref: https://learn.microsoft.com/en-us/training/modules/develop-for-azure-cache-for-redis/4-interact-redis-api
upvoted 2 times
...
rolling_potato_
2 years, 3 months ago
Was on my exam today (03-01-2023) I went with IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("teams")
upvoted 3 times
...
st0rmtrooperx
2 years, 4 months ago
Got this on Dec 16th, 2022. I scored 921 and used given answer.
upvoted 2 times
...
coffecold
2 years, 6 months ago
It is stringset, you want to have the key with the team name kept in your session. Please see the GetFromList() code in the tutorial (https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-web-app-cache-aside-leaderboard) if (String.IsNullOrEmpty(serializedTeams)) then the DB will be read instead of the cache and the cache is set again with string set. Implementation with an empty string returned from cache if invalidated is no problem.
upvoted 2 times
...
serpevi
2 years, 7 months ago
Got it on 09/2022, went with: IDatabase cache = connection.GetDatabase(); cache.KeyDelete("teams","). Score 927
upvoted 3 times
...
Eltooth
2 years, 10 months ago
IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("Team");
upvoted 2 times
...
lllleroiv
2 years, 10 months ago
IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("Team");
upvoted 1 times
...
liuliangzhou
2 years, 10 months ago
Answer is: IDatabase cache = Connection.GetDatabase(); cache.StringSet("Team") Per the subject mentioned: You need to invalidate the cache when team data is changed. It is changing value, not delete the object. we can update value for next time with no need re-create "Team" object. https://azure.microsoft.com/sv-se/blog/lap-around-azure-redis-cache-preview/
upvoted 6 times
...
meoukg
3 years, 1 month ago
Got it on 03/2022, I chose as below: 1. IDatabase cache = connection.GetDatabase(); 2. cache.KeyDelete("teams",")
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago