public RoutingAction ReadAction(string url, string key) { cacheLock.EnterReadLock(); try { RoutingAction action = null; _cache[url].actions.TryGetValue(key, out action); return(action); } finally { cacheLock.ExitReadLock(); } }
public void AddOrUpdateAction(string url, string key, RoutingAction action) { cacheLock.EnterUpgradeableReadLock(); try { RoutingAction result = null; if (_cache[url].actions.TryGetValue(key, out result)) { { cacheLock.EnterWriteLock(); try { result.action = action.action; result.actionName = action.actionName; result.IsDefAction = action.IsDefAction; result.modifyDate = action.modifyDate; result.attribute = action.attribute; result.param = action.param; result.returnType = action.returnType; } finally { cacheLock.ExitWriteLock(); } } } else { cacheLock.EnterWriteLock(); try { _cache[url].actions.Add(key, action); } finally { cacheLock.ExitWriteLock(); } } } finally { cacheLock.ExitUpgradeableReadLock(); } }