I’ve been diving back into the cache sections of NHibernate
lately and I started wondering what the value of placing a lock on the Get of a
cache item from ReadOnly cache is. It doesn’t seem to provide any
value to me. It’s not like we perform some additional operation if
the value isn’t there. There’s no lock in
NonstrictReadWriteCache or the Hibernate ReadOnlyCache version.
NonStrictReadWrite doesn’t have a lock on the Put
either and I’m not totally sure about the value of it on the ReadOnlyCache.
MinimalPut is a passed in parameter and it really shouldn’t change
throughout the life of the app domain and a get from the cache provider isn’t
guaranteed to be thread safe anyways. Just not sure how much we are gaining
with the lock.
I’d like to remove the locks if we could. Seems like
it would help with cache performance in a multithreaded app.
Any thoughts?
Jesse