Multithreaded app & Cache initialization

Dec 15, 2010 at 3:40 PM

First of all, thank you for so nice job! I have one question. Right now i do not understand how correctly implement one thing. I have multithreded application. In each thread i have to access named cache "Test" for example. If i will initialize named cache once CacheBroker.SetNamedCache(cacheName); first thread will go to Test cache, but others to default. So every time i need to perform get, set or other operation i check if it's using default cache or not, if not, then CacheBroker.SetNamedCache(cacheName); and only then do operations with cache. What is the right solution there ?

Coordinator
Dec 16, 2010 at 3:34 PM
Hello,
Thanks for your encouragement!  Please check-out the new release! (Stable Version) (http://cache4dotnet.codeplex.com/)
As I understand, you access a named cache (e.g. "Test") in multiple threads.  I think you have understood it correctly.  However, just to confirm, here is my suggestion:
In this situation, I would recommend you to use the "CacheBroker.SetNamedCache(cacheName);" before invoking the other API methods in a thread to use NamedCache.  The reason being some other thread may want to use a default cache and is a more common scenario.
 
Please feel free to ask questions about the usage as currently, I couldn't add documentation yet. Smile
 
Hope it helps!
 
Thanks & Regards,
Rahul