PrepAway - Latest Free Exam Questions & Answers

How should you complete the relevant code?

HOTSPOT
You are developing an ASP.NET MVC application that will be hosted on Microsoft Azure. The application
includes the StackExchange.Redis client package. A variable named CacheConnectionConfiguration stores the
cache endpoint URL and the password to connect to the cache.
The application must store a user’s color selection by using the Azure Redis cache. The cached value must
expire after 90 minutes. You need to cache the user’s color selection.
How should you complete the relevant code? To answer, choose the appropriate code segment from each list
in the answer area.
Hot Area:

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
Box 1: var cache = connection.GetDatabase():
Oncethe connection is established, return a reference to the redis cache database by calling the
ConnectionMultiplexer.GetDatabase method.Box 2: cache StringSet(“color”, colorSelection,TimeSpan.FromMinutes(90));
The TimeSpanFromMinutes method returns a TimeSpan that represents a specified number of minutes, where
the specification is accurate to the nearest millisecond.
Example: The following code snippet shows how to set an expiration time of 90 minutes on a key.
// Add a key with an expiration time of 90minutes
await cache.StringSetAsync(“data:key1”, 99, TimeSpan.FromMinutes(90));
https://docs.microsoft.com/en-us/azure/redis-cache/cache-dotnet-how-to-use-azure-redis-cache
https://msdn.microsoft.com/en-us/library/system.timespan.fromminutes(v=vs.110).aspx


Leave a Reply