Class LurchTable<TKey, TValue>
LurchTable stands for "Least Used Recently Concurrent Hash Table" and has definate similarities to both the .NET 4 ConcurrentDictionary as well as Java's LinkedHashMap. This gives you a thread-safe dictionary/hashtable that stores element ordering by insertion, updates, or access. In addition it can be configured to use a 'hard-limit' count of items that will automatically 'pop' the oldest item in the collection.
Inheritance
Assembly: DistributedLucene.Net.dll
Syntax
public class LurchTable<TKey, TValue> : IDictionary<TKey, TValue>, IDisposable
Type Parameters
Name | Description |
---|---|
TKey | The type of keys in the dictionary. |
TValue | The type of values in the dictionary. |
Constructors
Name | Description |
---|---|
LurchTable(LurchTableOrder, Int32) | Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached. |
LurchTable(LurchTableOrder, Int32, IEqualityComparer<TKey>) | Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached. |
LurchTable(LurchTableOrder, Int32, Int32, Int32, Int32, IEqualityComparer<TKey>) | Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached. |
LurchTable(Int32) | Creates a LurchTable that can store up to (capacity) items efficiently. |
LurchTable(Int32, LurchTableOrder) | Creates a LurchTable that can store up to (capacity) items efficiently. |
LurchTable(Int32, LurchTableOrder, IEqualityComparer<TKey>) | Creates a LurchTable that can store up to (capacity) items efficiently. |
Properties
Name | Description |
---|---|
Comparer | Retrives the key comparer being used by this instance. |
Count | Gets the number of elements contained in the System.Collections.Generic.ICollection<>. |
Item[TKey] | Gets or sets the element with the specified key. |
Keys | Gets an System.Collections.Generic.ICollection<> containing the keys of the System.Collections.Generic.IDictionary<TKey, TValue>. |
Limit | Gets or Sets the record limit allowed in this instance. |
Ordering | Retrieves the LurchTableOrder Ordering enumeration this instance was created with. |
Values | Gets an System.Collections.Generic.ICollection<> containing the values in the System.Collections.Generic.IDictionary<TKey, TValue>. |
Methods
Name | Description |
---|---|
Add(TKey, TValue) | Adds an element with the provided key and value to the System.Collections.Generic.IDictionary<TKey, TValue>. |
AddOrUpdate(TKey, TValue, KeyValueUpdate<TKey, TValue>) | Adds a key/value pair to the System.Collections.Generic.IDictionary<TKey, TValue> if the key does not already exist, or updates a key/value pair if the key already exists. |
AddOrUpdate(TKey, Func<TKey, TValue>, KeyValueUpdate<TKey, TValue>) | Adds a key/value pair to the System.Collections.Generic.IDictionary<TKey, TValue> if the key does not already exist, or updates a key/value pair if the key already exists. |
AddOrUpdate<T>(TKey, ref T) | Add, update, or fetche a key/value pair from the dictionary via an implementation of the CSharpTest.Net.Collections.ICreateOrUpdateValue`2 interface. |
Clear() | Removes all items from the System.Collections.Generic.ICollection<>. |
ContainsKey(TKey) | Determines whether the System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the specified key. |
Dequeue() | Removes the oldest entry in the collection based on the ordering supplied to the constructor. If an item is not available a busy-wait loop is used to wait for for an item. |
Dispose() | Clears references to all objects and invalidates the collection |
GetEnumerator() | Returns an enumerator that iterates through the collection. |
GetOrAdd(TKey, TValue) | Adds a key/value pair to the System.Collections.Generic.IDictionary<TKey, TValue> if the key does not already exist. |
GetOrAdd(TKey, Func<TKey, TValue>) | Adds a key/value pair to the System.Collections.Generic.IDictionary<TKey, TValue> if the key does not already exist. |
Initialize() | WARNING: not thread-safe, reinitializes all internal structures. Use Clear() for a thread-safe delete all. If you have externally provided exclusive access this method may be used to more efficiently clear the collection. |
Peek(out KeyValuePair<TKey, TValue>) | Retrieves the oldest entry in the collection based on the ordering supplied to the constructor. |
Remove(TKey) | Removes the element with the specified key from the System.Collections.Generic.IDictionary<TKey, TValue>. |
TryAdd(TKey, TValue) | Adds an element with the provided key and value to the System.Collections.Generic.IDictionary<TKey, TValue>. |
TryAdd(TKey, Func<TKey, TValue>) | Adds an element with the provided key and value to the System.Collections.Generic.IDictionary<TKey, TValue> by calling the provided factory method to construct the value if the key is not already present in the collection. |
TryDequeue(out KeyValuePair<TKey, TValue>) | Removes the oldest entry in the collection based on the ordering supplied to the constructor. |
TryDequeue(Predicate<KeyValuePair<TKey, TValue>>, out KeyValuePair<TKey, TValue>) | Removes the oldest entry in the collection based on the ordering supplied to the constructor. |
TryGetValue(TKey, out TValue) | Gets the value associated with the specified key. |
TryRemove(TKey, out TValue) | Removes the element with the specified key from the System.Collections.Generic.IDictionary<TKey, TValue>. |
TryRemove(TKey, KeyValuePredicate<TKey, TValue>) | Removes the element with the specified key from the System.Collections.Generic.IDictionary<TKey, TValue> if the fnCondition predicate is null or returns true. |
TryRemove<T>(TKey, ref T) | Conditionally removes a key/value pair from the dictionary via an implementation of the CSharpTest.Net.Collections.IRemoveValue`2 interface. |
TryUpdate(TKey, TValue) | Updates an element with the provided key to the value if it exists. |
TryUpdate(TKey, TValue, TValue) | Updates an element with the provided key to the value if it exists. |
TryUpdate(TKey, KeyValueUpdate<TKey, TValue>) | Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the syncronization lock. |
Events
Name | Description |
---|---|
ItemAdded | Event raised after an item is added to the collection |
ItemRemoved | Event raised after an item is removed from the collection |
ItemUpdated | Event raised after an item is updated in the collection |