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.

Answer:

Explanation:

Box 1: var cache = connection.GetDatabase():

Once the 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.

Explanation: 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 90 minutes

await cache.StringSetAsync("data:key1", 99, TimeSpan.FromMinutes(90));

References: 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

Latest 70-486 Dumps Valid Version with 255 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments