Which code segment can you use?

Correct Answer for the following Question is given below

The GetVendors() action in the ProcessedOrderController controller is querying the database each time it is run. The GetVendors() action must query the database only if the cache is null.You need to add code to the action at line PC33 to cache the data.Which code segment can you use? (Each correct answer presents a complete solution. Choose all that apply.)

Question:

Which code segment can you use?

Options:

cache.Set(new CacheItem(“vendorKey”, vendors), GetVendorPolicy());

cache.Add(“vendors”, vendors, new CacheItemPolicy());

cache.Add(new CacheItem(“vendorKey”, vendors) , GetVendorPolicy());

cache.AddOrGetExisting(“vendorKey”, context, new CacheItemPolicy());

Correct Answer

The Correct Answer for this Question is

cache.Set(new CacheItem(“vendorKey”, vendors), GetVendorPolicy());
cache.Add(new CacheItem(“vendorKey”, vendors) , GetVendorPolicy());

Explanation

The Question – Which code segment can you use? has been answered correctly and answers for the question is cache.Set(new CacheItem(“vendorKey”, vendors), GetVendorPolicy());
cache.Add(new CacheItem(“vendorKey”, vendors) , GetVendorPolicy());

More about these Exams

These Exam Questions and the order of these questions keep changing. but the answers are obviously same. so if you don’t find a question after another we suggest you search it in the search box and we are sure you’ll find it. you can bookmark this site for Quick access in future.

We hope you found it helpful don’t forget to leave a comment if you feel a need to correct or ask we’re always here to help.

you can find more here at mnccertified

Feel free to contact via comment or email.

Happy Learning

Cheers, Team MNCcertified

Leave a Comment