Click or drag to resize
ExpiringDictionaryTKey, TValue Class
Manages a self-expiring dictionary of items.
Inheritance Hierarchy
SystemObject
  VirtualRadar.InterfaceExpiringCollectionTValue
    VirtualRadar.InterfaceExpiringDictionaryTKey, TValue

Namespace: VirtualRadar.Interface
Assembly: VirtualRadar.Interface (in VirtualRadar.Interface.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public class ExpiringDictionary<TKey, TValue> : ExpiringCollection<TValue>
where TValue : class

Type Parameters

TKey
The type of key being held by the collection.
TValue
The type of value being held by the collection.

The ExpiringDictionaryTKey, TValue type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAfterCheckForExpiredItemsDelegate
Gets or sets an optional delegate that is called after the check for expired items is made.
(Inherited from ExpiringCollectionTItem.)
Public propertyBeforeCheckForExpiredItemsDelegate
Gets or sets an optional delegate that is called before the check is made for expired items.
(Inherited from ExpiringCollectionTItem.)
Public propertyCount
Gets the current count of items in the dictionary.
(Overrides ExpiringCollectionTItemCount.)
Public propertyCountChangedDelegate
Gets or sets an optional delegate that is called when the count changes. The new count is passed to the delegate. The list is locked to the calling thread while the delegate is running. The delegate will occasionally be called on a background thread.
(Inherited from ExpiringCollectionTItem.)
Public propertyExpireMilliseconds
Gets or sets the minimum number of milliseconds that an item can remain within the list.
(Inherited from ExpiringCollectionTItem.)
Public propertyGetExpiredItemsDelegate
Gets or sets an optional delegate that returns the collection of the keys of expired items. If this delegate is present then it is always used in preference to the timestamps attached to the item and the Refresh methods will have no effect.
Public propertyMillisecondsBetweenChecks
Gets or sets the minimum number of milliseconds to wait between checks for expiring items.
(Inherited from ExpiringCollectionTItem.)
Top
Methods
  NameDescription
Public methodAdd
Adds an item to the dictionary.
Public methodChangeIntervals
Changes the intervals for the expiration of items and the interval between checks.
(Inherited from ExpiringCollectionTItem.)
Public methodClear
Empties the dictionary.
(Overrides ExpiringCollectionTItemClear.)
Public methodDispose
See interface docs.
(Inherited from ExpiringCollectionTItem.)
Protected methodDispose(Boolean)
Disposes of or finalises the object.
(Inherited from ExpiringCollectionTItem.)
Protected methodDoRemoveExpiredItems
See base docs.
(Overrides ExpiringCollectionTItemDoRemoveExpiredItems(DateTime).)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Finalises the object.
(Inherited from ExpiringCollectionTItem.)
Public methodFind
Finds the first value that matches the predicate passed across or null if no such value could be found.
Public methodFindAll
Returns a list of all values that match the predicate passed across.
Public methodFindAllAndRefresh
Returns a list of all values that match the predicate passed across. Refreshes the timestamps for all items returned.
Public methodFindAndRefresh
Finds the first value that matches the predicate passed across or null if no such value could be found. Refreshes the timestamp on the value if it could be found.
Public methodGetAndRefreshOrCreate
Returns the item for the key passed across or calls the create method to create a new item and add it to the dictionary. If the item already exists then its timestamp is refreshed.
Public methodGetForKey
Returns the item for the key passed across. Returns null if the key is no longer in the dictionary.
Public methodGetForKeyAndRefresh
Returns the item for the key passed across. Returns null if the key is no longer in the dictionary. Refreshes the item's timestamp.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetOrCreate
Returns the item for the key passed across or calls the create method to create a new item and add it to the dictionary.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodHookHeartbeat
Hooks the heartbeat event. Must be called from within a lock.
(Inherited from ExpiringCollectionTItem.)
Public methodLock
Calls the action passed across with the list locked. Do not perform an action that will attempt to lock the list from another thread, it will block.
(Inherited from ExpiringCollectionTItem.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnCountChanged
Called by the derivee to inform the owner of the collection that the count has changed. Always call this from within a lock.
(Inherited from ExpiringCollectionTItem.)
Public methodRefreshAll
Refreshes all of the timestamps in the dictionary.
Public methodRemoveExpiredItems
Removes expired items.
(Inherited from ExpiringCollectionTItem.)
Public methodRemoveIfExists
Removes the item for the key passed across. Does nothing if the key does not exist.
Public methodSnapshot
Returns a snapshot of all of the key-value pairs in the dictionary.
Public methodSnapshotAndRefresh
Returns a snapshot of all of the key-value pairs in the dictionary and refreshes the timestamps on all of them.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodUnhookHeartbeat
Unhooks the heartbeat service if hooked. Must be called from within a lock.
(Inherited from ExpiringCollectionTItem.)
Public methodUpsert
Adds or updates an item in the dictionary. If the key is already in use then the value is overwritten but the timestamp is not refreshed.
Public methodUpsertAndRefresh
Adds or updates an item in the dictionary. If the key is already in use then the value is overwritten and the timestamp is refreshed.
Public methodUpsertRange
Adds or updates a range of items. If an item exists then it is updated but its timestamp is not refreshed.
Public methodUpsertRangeAndRefresh
Adds or updates a range of items. If an item exists then it is updated and its timestamp is refreshed.
Top
Fields
Remarks
When an item is added to this dictionary it is given a timestamp. The items in the dictionary are periodically checked, if they have been in the map for longer than ExpireMilliseconds then they are removed. This class is thread-safe.
See Also