2

Can I Use Microsoft Enterprise Library Caching in Load Balance servers?, My case is I have a web service located in 2 load balance servers, and I use Database Cache "backingStores" with configuration like below

<cachingConfiguration defaultCacheManager="Cache Manager">
    <cacheManagers>
        <add name="Cache Manager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="MyDataCacheStorage11"/>
    </cacheManagers>
    <backingStores>
        <add name="MyDataCacheStorage11" type="Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" encryptionProviderName="" databaseInstanceName="EntLib1ConnectionString111" partitionName="CAPwiki Cache"/>
        <add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="NullBackingStore"/>
    </backingStores>
</cachingConfiguration>

and when I set cache with key "_testorderstatus3" from server1 and try to get it from server2, it returns Null value!!!

also when I set value with same key from server1 and set it again from server2, and I check the DB, I found it set 2 times as shown below enter image description here

any idea about that? i need to set and get in both servers.

Thank you

Tarek El-Mallah
  • 4,015
  • 1
  • 31
  • 46

1 Answers1

3

Enterprise Library doesn't support an out of the box distributed multi-server cache solution. From Chapter 5 of the Developer's Guide:

Out of the box, the Caching Application Block does not provide the features required for distributed caching across multiple servers.

Based on what you are trying to do I would take a look at Windows Server AppFabric Caching Services.

Windows Server AppFabric provides a distributed in-memory application cache platform for developing scalable, available, and high-performance applications.

Randy Levy
  • 22,566
  • 4
  • 68
  • 94
  • Thank you, but are there any way to make the Enterprise library distributed multi-server cache? and do you have a documentation lists that no out of the box distributed multi-server cache solution? -Thank you – Tarek El-Mallah Oct 18 '11 at 17:13
  • @TarekEl-Mallah, I'm fairly sure that you could implement a distributed multi-server cache using Enterprise Library. But why go through all that development and testing when there **are** out of the box solutions out there? – Randy Levy Oct 18 '11 at 17:22
  • Thank you, is the "Windows Server AppFabric" free to use or something I must buy? and are there a code sample for it – Tarek El-Mallah Oct 18 '11 at 18:40
  • 2
    Windows Server AppFabric is free (not be confused with Azure AppFabric). Go to [their homepage](http://msdn.microsoft.com/appfabric) -- they have a lot of resources there. Also, see [this](http://stackoverflow.com/questions/4739548/appfabric-caching-examples-using-c-sharp) example. – Randy Levy Oct 18 '11 at 19:27