exam questions

Exam AZ-203 All Questions

View all questions & answers for the AZ-203 exam

Exam AZ-203 topic 5 question 9 discussion

Actual exam question from Microsoft's AZ-203
Question #: 9
Topic #: 5
[All AZ-203 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:
Box 1: IDatabase cache = connection.GetDatabase();
Connection refers to a previously configured ConnectionMultiplexer.
Box 2: cache.StringSet("teams",")
To specify the expiration of an item in the cache, use the TimeSpan parameter of StringSet. cache.StringSet("key1", "value1", TimeSpan.FromMinutes(90));
References:
https://azure.microsoft.com/sv-se/blog/lap-around-azure-redis-cache-preview/

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
ac3ju
Highly Voted 5 years, 5 months ago
IDatabase.KeyDelete looks better solution https://csharp.hotexamples.com/examples/-/IDatabase/KeyDelete/php-idatabase-keydelete-method-examples.html
upvoted 32 times
...
predator
Highly Voted 5 years, 4 months ago
Correct Answer: cache.KeyDelete Scenario: You need to invalidate the cache when team data is changed.
upvoted 16 times
predator
5 years, 4 months ago
Source: https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-web-app-cache-aside-leaderboard
upvoted 13 times
...
VK_Gladiator
4 years, 6 months ago
code snippted. void ClearCachedTeams() { IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("teamsList"); cache.KeyDelete("teamsSortedSet"); ViewBag.msg += "Team data removed from cache. "; } Reference link: https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-web-app-cache-aside-leaderboard
upvoted 4 times
...
...
meoukg
Most Recent 3 years, 3 months ago
Got it on 03/2022, I chose as below: 1. IDatabase cache = connection.GetDatabase(); 2. cache.KeyDelete("teams",")
upvoted 1 times
...
victor
4 years, 4 months ago
KeyDelete Seems to be more appropriate here.. For invalidating cache you can either use StringSet with expiration time as parameter or simply remove key by removing it using keydelete As question dosen't talk about any expiration time i think most appropriate answer is KeyDelete
upvoted 1 times
...
ExamStudent123
4 years, 11 months ago
Exact code sample found on this page: https://docs.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 7 times
Juanlu
4 years, 7 months ago
Agree. After check it in a quick sample, StringSet("Key1", ""), cannot pass a null as a second parameter, so could be a solution but no a good one. Finally I can say, the best answer is: åcache.keyDelete
upvoted 2 times
...
...
Ananas
4 years, 11 months ago
As far as I understand, SetKey is useful to set an expiration time, while here we have to invalidate the cache when data changes, so KeyDelete seems to be the right choice. As an example, from microsoft docs: void ClearCachedTeams() { IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("teamsList"); cache.KeyDelete("teamsSortedSet"); ViewBag.msg += "Team data removed from cache. "; }
upvoted 1 times
...
niloySubs
4 years, 11 months ago
to invaliate redis cache - you need to delete the key from redis cache. You can Visit this link for the entire program\case study: https://docs.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. "; } Correct Answer is : IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("xxxxxxxxx");
upvoted 8 times
...
brajen
4 years, 11 months ago
Do not get confuse..given answer is correct only . Here you can just reset the value of the Key to invalidate the data..so need not to delete the key. option cache.StringSet("Teams") is the correct option
upvoted 2 times
...
mcampos
5 years ago
Cache.KeyDelete https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-web-app-cache-aside-leaderboard
upvoted 1 times
...
heero
5 years, 3 months ago
void ClearCachedTeams() { IDatabase cache = Connection.GetDatabase(); cache.KeyDelete("teamsList"); cache.KeyDelete("teamsSortedSet"); ViewBag.msg += "Team data removed from cache. "; }
upvoted 11 times
...
Dumindu
5 years, 3 months ago
cache.KeyDelete is the answer
upvoted 8 times
...
Khang
5 years, 5 months ago
To invalid the cache you should delete
upvoted 9 times
TRUESON
5 years, 5 months ago
there is keydelete but no value delete
upvoted 2 times
warchoon
2 years, 3 months ago
Setting an Empty string is not a deletion. It's just another wrong cache
upvoted 1 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 ...