Commit 6f28e5c8 authored by mgravell's avatar mgravell

remove ReaderWriterLockSlim - not needed

parent dd154e4a
......@@ -31,31 +31,16 @@ class CacheInfo
public Action<IDbCommand, object> ParamReader { get; set; }
}
#if CSHARP30
private static readonly System.Threading.ReaderWriterLockSlim queryLock = new System.Threading.ReaderWriterLockSlim();
private static readonly Dictionary<Identity, CacheInfo> _queryCache = new Dictionary<Identity, CacheInfo>();
// note: conflicts between readers and writers are so short-lived that it isn't worth the overhead of
// ReaderWriterLockSlim etc; a simple lock is faster
private static void SetQueryCache(Identity key, CacheInfo value)
{
queryLock.EnterWriteLock();
try
{
_queryCache[key] = value;
}
finally
{
queryLock.ExitWriteLock();
}
lock (_queryCache) { _queryCache[key] = value; }
}
private static bool TryGetQueryCache(Identity key, out CacheInfo value)
{
queryLock.EnterReadLock();
try
{
return _queryCache.TryGetValue(key, out value);
}
finally
{
queryLock.ExitReadLock();
}
lock (_queryCache) { return _queryCache.TryGetValue(key, out value); }
}
#else
static readonly System.Collections.Concurrent.ConcurrentDictionary<Identity, CacheInfo> _queryCache = new System.Collections.Concurrent.ConcurrentDictionary<Identity, CacheInfo>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment