PrepAway - Latest Free Exam Questions & Answers

Which code segment should you add?

You are implementing a method in an ASP.NET application that includes the following requirements.
* Store the number of active bugs in the cache.
* The value should remain in the cache when there are calls more often than every 15 seconds.
* The value should be removed from the cache after 60 seconds.

You need to add code to meet the requirements.
Which code segment should you add?

PrepAway - Latest Free Exam Questions & Answers

A.
Cache.Insert(“ActiveBugs”, result, null, DateTime.Now.AddSeconds(60), TimeSpan.FromSeconds(15));

B.
Cache.Insert(“Trigger”, DateTime.Now, null, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration);
CacheDependency cd = new CacheDependency(null, new string[] { “Trigger” });
Cache.Insert(“ActiveBugs”, result, cd, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15));

C.
Cache.Insert(“ActiveBugs”, result, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15));
CacheDependency cd = new CacheDependency(null, new string[] { “ActiveBugs” });
Cache.Insert(“Trigger”, DateTime.Now, cd, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration);

D.
CacheDependency cd = new CacheDependency(null, new string[] { “Trigger” });
Cache.Insert(“Trigger”, DateTime.Now, null, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration);
Cache.Insert(“ActiveBugs”, result, cd, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(15));

Explanation:
doubtful answer

2 Comments on “Which code segment should you add?

  1. aaa says:

    You cannot set both the absoluteExpiration and slidingExpiration parameters. If you intend the cache item to expire at a specific time, you set the absoluteExpiration parameter to the specific time, and the slidingExpiration parameter to NoSlidingExpiration.




    0



    0

Leave a Reply