EnterpriseLibrary Caching in Load Balance

2k views Asked by At

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

1

There are 1 answers

4
Randy Levy On BEST ANSWER

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.