views:

167

answers:

2

I read some articles about SqlCacheDependency. I think it is a really cool way for updating caches, but i'm not sure how i can handle this technologie if my application is a n-tier architekture.

Is this just useful if my program is a small webapplication, or is there also a way for use in big n-tier architektures?

A: 

In this case, you would need to have your DAL return you an object that derives from the CacheDependency abstract class, that would do the same thing as SqlCacheDependency, but optimized for your DAL.

This is, of course, a failure of separation of concerns, but if you need the dependency, it's the best way to go.

John Saunders
Do you think it is a "good-style" to use this class in a DAL of a n-tier architekture? Like you, I don't think so. Conclusion: I nice class, but only for small apps.
michl86
Yes, I think it's unfortunate Microsoft didn't define an ICacheDependency interface, which might have been ok to expose from a DAL. I don't like a DAL using System.Web.
John Saunders
+1  A: 

You can create your own ICacheDependency interface and use a factory class to give you the appropriate object. This way neither your DAL or BL need to reference System.Web namespace. You can put this factory class in a common tier and reference it in the UI layer.

MS Petshop 4 has used something like this, you may want to follow that.

Vivek
really good example in petshop 4! thanks a lot!
michl86