Following on from logging, the other aspect we’re using is caching. Goal is similar, make it really easy to cache but not litter the code with lots of calls to caches (or worse, random static dictionaries hidden in classes). The motivation here is to solve the problem where you go off and look up a bit of meta-data and don’t want to keep going to the DB, or disk or wherever to get it. Also, I wanted it to be easy to apply, after running some profile traces you see some stuff that’d benefit from caching and you just turn it on.
This is not a my version of CouchDb, Mongo or whatever (I’ll leave that up to people with much more cranial capacity than myself!). It could easily use couch et al. as a cache store, but I’ve not really made my mind up on whether that would be a good idea. I think I’ll have a chat with some people over some beers one evening.
Keeping it simple was key here, it’s more complicated than the logging aspect, but I hope not much. One thing that made me quite happy was the new concurrent dictionary in .Net 4.
Here’s a few ways it can be configured:
As you can see from this and the logging configuration I’ve used extension methods on the component registration. This felt like the right place to do it and has proved easy to use. You don’t have to use the extension methods, they are just wrappers. I’m really leaning on Windsor as much as I can, it’s saving me time and I hope giving people an easy to use API. One thing I don’t like is the number of brackets…