So right now I have come into a project that I’m taking over the responsibility for.
One part I found that is halfway implemented is a service layer cache. Apparently this cache in the service layer was implemented to avoid a high amount of calls do the database cluster. The service layer is hosted on two servers for performance and stability if one server goes down.
Now to my problem, or rather, what is the best pattern for the implementation of a timed cache? Objects that rarely changes or are updated, like countries etc are cached and never really released if not the pool is reset.
Because we, or rather my predecessors, have two active services on two separate machines I’m thinking about implementing a timed cache.
An alternative could be to have the services talk with each others but of course taking into account that they are not dependent on each others so that if one goes down the other will work just fine.
Right now there are 12 dictionaries with items that are cached. Most of these are rarely updated. These dictionaries resides in one class that is not a singleton but is implemented as a singleton so it is only instantiated once.
How do you advice me to solve this interesting problem and why that way?
Why not setup a cache cluster consisting out one or multiple servers, using one of the following caching technologies:
This way you don’t have to worry about running two services doing the same thing.
Both these technologies support caching object for a specified about of time.
E.g.:
Or you can choose to cache them indefinitely.
Redudancy is supported. Be aware of the small print though.
AppFabric Redundancy
Back in 2010 I wrote some posts about AppFabric and NCache.
Both provide an easy and similar API to work with.