Enterprise Library Caching without configuration#

I've been using Enterprise Library 2.0 quite a lot lately, and although the configuration part is truly excellent and easy to use, sometimes you just want to use some block without going through configuration. In my case, I wanted to use a cache somewhere in a piece of framework code without requiring users of that code to add anything "magic" to their application configuration to make it work. So with a little help of Brian Button, I cooked up the following code to create a standard CacheManager with an in-memory backing store:

DictionaryConfigurationSource internalConfigurationSource = new DictionaryConfigurationSource();
CacheManagerSettings settings = new CacheManagerSettings();
internalConfigurationSource.Add(CacheManagerSettings.SectionName, settings);
CacheStorageData storageConfig = new CacheStorageData("Null Storage", typeof(NullBackingStore));
settings.BackingStores.Add(storageConfig);
CacheManagerData cacheManagerConfig = new CacheManagerData("CustomCache", 60, 1000, 10, storageConfig.Name);
settings.CacheManagers.Add(cacheManagerConfig);
settings.DefaultCacheManager = cacheManagerConfig.Name;
CacheManagerFactory cacheFactory = new CacheManagerFactory(internalConfigurationSource);
CacheManager customCache = cacheFactory.CreateDefault();

So this piece of code in fact creates the configuration objects directly and passes them on to the CacheManagerFactory to use so it doesn't go about reading any configuration files. Pretty simple once you get the hang of it, and pretty powerful for the cases you want to use Enterprise Library "behind the scenes".

Check out Brian's blog for an example on Exception Handling without using an external configuration file. By the way: thanks for all your work on EntLib and all the best in your career move, Brian!

Blog | Programming | .NET | EntLib | Samples
Tuesday, March 28, 2006 9:06:35 AM (Romance Standard Time, UTC+01:00) #    Comments [0]  | 

 

Developer & IT Pro Days 2006#

It's been a hectic and busy couple of weeks leading up to the Belgian Developer & IT Pro Days in Ghent last week, but it was all worth it! Steven and I had a lot of fun presenting our sessions, and it was great to meet a lot of interesting new people and to talk to some people who I hadn't seen in a while.

I know that we haven't been able to upload the final versions of the slides to the official site on time, but a lot of you have been asking for them so here they are:

Best Practices In Framework Design (1.85 MB)

Best Practices For Application Development (2.12 MB)

During this last presentation, we showed demos of Enterprise Library 2.0 and a very cool (IMHO) implementation of the Command Pattern using Enterprise Library to add some aspects such as logging and security. You can find the source for the first demo (Enterprise Library only) here:

Demo 01 - Enterprise Library.zip (1.46 MB)

Steven has posted the second demo along with the source code for the Command Pattern on his blog, so you can get that from there!

In conclusion, it was a great event that really made all the efforts of the past weeks worthwile. So a lot of thanks to the organizing team (great job Tom, David, Ritchie!) and for all that attended!

Hope to see you again next year!

Tuesday, March 14, 2006 9:15:32 AM (Romance Standard Time, UTC+01:00) #    Comments [0]  | 

 

My article is headlining on MSDN#

Now it may not get me the same amount of groupies as headlining on Rock Werchter, but apparently my article on The Command Pattern in Windows Presentation Foundation is currently the top headline on the home page of the Windows Vista Developer Center at MSDN! Woohoo!

Thanks David for pointing it out to me!

Blog | Programming | .NET | WPF
Monday, March 06, 2006 12:03:12 PM (Romance Standard Time, UTC+01:00) #    Comments [10]  | 

 

All content © 2010, Jelle Druyts
On this page
Enterprise Library Caching without configuration
Developer & IT Pro Days 2006
My article is headlining on MSDN

Recent Photos
www.flickr.com
This is a Flickr badge showing public photos from Jelle Druyts. Make your own badge here.
Advertising
Top Picks
Statistics
Total Posts: 350
This Year: 4
This Month: 2
This Week: 2
Comments: 526
Archives
Sitemap
Disclaimer
This is my personal website, not my boss', not my mother's, and certainly not the pope's. My personal opinions may be irrelevant, inaccurate, boring or even plain wrong, I'm sorry if that makes you feel uncomfortable. But then again, you don't have to read them, I just hope you'll find something interesting here now and then. I'll certainly do my best. But if you don't like it, go read the pope's blog. I'm sure it's fascinating.

Powered by:
newtelligence dasBlog 2.0.7226.0

Sign In