70-513 · Question #243
You are developing a Windows Communication Foundation (WCF) service to provide an in- memory cache. The following code is part of your solution. (Line numbers are included for reference only.) 02…
The correct answer is B. At line 12, replace InstanceContextMode.Single with D. Insert the following code at line 01. See the full explanation below for the reasoning.
Question
You are developing a Windows Communication Foundation (WCF) service to provide an in- memory cache. The following code is part of your solution. (Line numbers are included for reference only.) 02 Public Interface IlnMemoryCacheService 04 <OperationContract()> 05 Function GetCachedItem( ByVal key As String) As String 07 <OperationContract() > 08 Sub CacheItem( ByVal key As String, ByVal item As String) 10 End Interface 12 <ServiceBehavior( InstanceContextMode:=InstanceContextHode.Single)> 13 Public Class CacheService 14 Implements IlnHemoryCacheService 16 Dim cache As Hashtatale - New Hashtable)> 18 Public Function GetCachedItem( ByVal key As String) As String mplements IInHemoryCacheService.GetCachedltem 20 Return cache (key) .ToStrlng() 22 End Function 24 Public Sub Cacheltem( ByVal key As String, ByVal item As String) Implements ilnMemoryCacheService.Cacheltem Then 26 If (cache.Contains(key) 27 cache.Remove(key) 28 End If 30 cache.Add(key, item) 32 End Sub 34 End Class Users report that the cache is getting updated with cache changes of other users. You need to ensure that each user's cache is maintained and isolated from other users. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
Options
- AInsert the following code at line 01.
- BAt line 12, replace InstanceContextMode.Single with
- CAt line 12, replace InstanceContextMode.Single with
- DInsert the following code at line 01.
How the community answered
(28 responses)- A7% (2)
- B79% (22)
- C14% (4)
Community Discussion
No community discussion yet for this question.