Effectively using Caching#

Since this has come up twice in the past couple weeks I figure there has to be more people out the wondering what are some scenarios they should be using the Enterprise Library Caching Block.  The EntLib caching block provides an easy way to create, manage and invalidate a cache. 

How many caches does one need?  This depends on your scenario.  For just a server application you most likely only need one.  What if there is a client that talks to the server?  You may think it is good enough to cache only on the server but given how easy it is to create and manage a cache with Entlib I would suggest also having a cache on the client.  This will most likely create two caches talking to each other via whatever interface you choose.

The above setup works just as well for inter application caching, say a messaging layer talking to an application layer.  The application layer is the gate keeper to the database which is where lookup codes are stored.  The messaging layer needs the lookup codes to map different codes between systems.  So in this scenario the application layer will have a cache which is surfaced via WCF and the Messaging layer will have a cache which retrieves the lookups via WCF from the cache on the application layer.  With this setup both layers get the advantage of using a cache and limits the amount of database hits for a fast massaging setup.

Thursday, March 29, 2007 2:10:53 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

using (TransactionScope){}#

TransactionScope is a great new feature in .NET 2.0 for managing transactions.  It exists in the System.Transactions namespace and more info can be found on MSDN.  There is also a good post from Jim Johnson on understanding how it works.

In .NET 1.1 a transaction had to be started at the highest point you wanted to wrap then everything would happen inside that transaction.  I hated this approach because the class doing the save may not be the one managing the transaction, it is most likely being managed by something higher in the chain.

In .NET 2.0 the use of TransactionScope now allows for nested transactions.  So instead of having one transaction very high in the chain of actions and being limited to one you can have nested transactions.  When one fails everything gets rolled back.  This makes a cleaner save model for using a pattern like the table data gateway.  A parent object may have children that will be saved.  Now the saving of the children can all start their own transaction and they are nested inside the parents transaction, fabulous!

Thursday, March 29, 2007 1:53:40 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

CR_ClassCleaner 1.3#

I just put up a new release of CR_ClassCleaner on CodePlex with updated references to the 2.1.3 release of DXCore.

Grab it while you can!

Tuesday, March 13, 2007 3:01:07 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Ground Loops just suck!#

I hate dealing with ground loops and they seem to pop up again and again.  Every time I add or change a component of my home theater the hum returns.

The easy one to solve is the cable line which is the main source of the hum.  Just visit parts express and buy a Dayton VIT-1 Video Isolation Transformer.

After installing the Isolation Transformer the hum will be weaker if not gone.  If it still exists there is some detective work to do.  My father found a great article describing how these ground loops are created and how to fix them.  It is a riveting tale of voltage potential and Ohm’s Law.

Saturday, March 03, 2007 3:32:23 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

All content © 2008, John Luif