public NodeAddResult AddNode(Node node) { lock (_nodeBucketLock) { if (_items.Count < BucketSize) { var item = new NodeBucketItem(node); if (!_items.Contains(item)) { _items.Add(item); } return(NodeAddResult.Added()); } var evictionCandidate = GetEvictionCandidate(); return(NodeAddResult.Full(evictionCandidate)); } }
public NodeAddResult AddNode(Node node) { lock (_nodeBucketLock) { if (_items.Count < BucketSize) { NodeBucketItem item = new NodeBucketItem(node, DateTime.UtcNow); if (!_items.Contains(item)) { _items.AddFirst(item); } return(NodeAddResult.Added()); } NodeBucketItem evictionCandidate = GetEvictionCandidate(); return(NodeAddResult.Full(evictionCandidate)); } }