.net - Does my IBackingStore need to be thread safe? -


The documentation for Enterprise Library says:

The way the cache object is operated, You are guaranteed that any banking store will be called in single-threaded manner. This means that you do not have to secure your implementation thread.

and related to the Cash Manager:

Each method created through the Cash Manager object is secure for call threads.

But a simple test proves the opposite:

Here's my custom backing store (only the ad is relevant)

  Public Class Mystore: Ibkingstore {Unstable bull is entered = false; #region IBackingStore Add Member Zero (CacheItem newCacheItem) {if (pointed) new NotImplementedException throw (); Enter = true; Thread.Sleep (1000); Enter = wrong; } Calculate public int {get (throw new non-emulated exposition); }} Throwing public zero flush () {new NotImplementedException ()}; } Public Systems oath. Hashable Load () {New System. Selection. Hashtable (); } Remove public Zero (String Key) {Throw New NotImplementedException; } Public Zero UpdateLastAccessedTime (String Key, Datetime Timestamp) {Throw New NotImplementedException; } #party # regional IDisposable member public zero extraction () {new NotImplementedException (); } #endregion}  

And here is an exam that has access to the same cash manager through two different threads:

  dictionaryConfigurationSource configSource = New DictionaryConfigurationSource (); CacheManagerSettings cacheSettings = New CacheManagerSettings (); ConfigSource.Add (CacheManagerSettings.SectionName, cache settings); CashStogadata storage sign = new cashstoredata ("Mystage", Typef (Mystore)); CacheSettings.BackingStores.Add (storageConfig); CacheManagerData cacheManagerData = New CacheManagerData ("CustomCache", 120, 100, 5, storageConfig.Name); CacheSettings.CacheManagers.Add (cacheManagerData); CacheSettings.DefaultCacheManager = cacheManagerData.Name; CacheManagerFactory cacheFactory = New CacheManagerFactory (configSource); ICacheManager cacheManager = cacheFactory.CreateDefault (); Thread thread = new thread ((=) gt; {cacheManager.Add ("item1", "odaiu");}); Thread.Start (); CacheManager.Add ("item2", "dzaoiudoiza");  

Add method is executed twice in separate threads (because it throws "NotImplementedException" of add method).

Is there anything wrong with my code or is the documentation for Enterprise Library incorrect?

Because the document is very clear about this, I would believe the documentation.

Your evidence is flawed that you are making a clear-vomit-throttled access case for the class. There is nothing implicit about specific interfaces that it will definitely fail if it makes threads secure.

The Enterprise Library is giving a guarantee that they will manage the interface with a thread securely. Internally they will take care to manage class yarn protection.

Note: I do not have any specific knowledge about this library, but with the documentation is clear, I believe in it.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -