Reputation: 413
Scenario:
Implement in-memory caching of master data in the WCF layer of an ASP.Net application for a web farm scenario
Our proposed solution:
We intend to have an external service/ exe/ web page which would be aware of all load balanced servers (via a configuration file). In order to invalidate a specific cache, we would invoke this external component which in turn would invalidate the respective cache key on all the web servers and load then cache with latest data.
The problem:
Although the above approach would work for us, we do not think it is a clean approach for an enterprise class LOB application. Is there a better/ cleaner way of achieving the cache expiry across multiple servers?
Note:
Upvotes: 0
Views: 846
Reputation: 15420
Comparing your design to Windows Azure In-Role Cache and AppFabric Cache.
In those products, the cache is stored in one or more servers (cache cluster). In order to speed up requests, they created Local Cache.
When local cache is enabled, the cache client stores a reference to the object locally. This local reference keeps the object active in the memory of the client application. When the application requests the object, the cache client checks whether the object resides in the local cache. If so, the reference to the object is returned immediately without contacting the server. If it does not exist, the object is retrieved from the server. The cache client then deserializes the object and stores the reference to this newly retrieved object in the local cache. The client application uses this same object.
The local cache can be invalidation by time-out and/or notification
Notification-based Invalidation
When you use cache notifications, your application checks with the cache cluster on a regular interval to see if any new notifications are available. This interval, called the polling interval, is every 300 seconds by default. The polling interval is specified in units of seconds in the application configuration settings. Note that even with notification-based invalidation, timeouts still apply to items in the local cache. This makes notification-based invalidation complementary to timeout-based invalidation.
Upvotes: 1