Class ChangeAwareCache<TObject, TKey>
- Namespace
- Dynamic
Data
- Assembly
- DynamicData.dll
A cache which captures all changes which are made to it. These changes are recorded until CaptureChanges() at which point thw changes are cleared. Used for creating custom operators.
public sealed class ChangeAwareCache<TObject, TKey> : ICache<TObject, TKey>, IQuery<TObject, TKey> where TObject : notnull where TKey : notnull
Type Parameters
TObjectThe value of the cache.
TKeyThe key of the cache.
- Inheritance
-
ChangeAwareCache<TObject, TKey>
- Extension Methods
Constructors
ChangeAwareCache()
Initializes a new instance of the ChangeAwareCache<TObject, TKey> class.
ChangeAwareCache(Dictionary<TKey, TObject>)
Initializes a new instance of the ChangeAwareCache<TObject, TKey> class.
Parameters
dataDictionary<TKey, TObject>Data to populate the cache with.
ChangeAwareCache(int)
Initializes a new instance of the ChangeAwareCache<TObject, TKey> class.
Parameters
capacityintThe capacity of the initial items.
Properties
Count
Gets the count.
Property Value
Items
Gets the items.
Property Value
- IEnumerable<TObject>
KeyValues
Gets the items together with their keys.
Property Value
- IEnumerable<Key
Value <TKey, TObject>>Pair The key values.
Keys
Gets the keys.
Property Value
- IEnumerable<TKey>
Methods
Add(TObject, TKey)
Adds the item to the cache without checking whether there is an existing value in the cache.
Parameters
itemTObjectThe item to add.
keyTKeyThe key to add.
AddOrUpdate(TObject, TKey)
Adds or updates the item using the specified key.
Parameters
itemTObjectThe item.
keyTKeyThe key.
CaptureChanges()
Create a change set from recorded changes and clears known changes.
Returns
- Change
Set <TObject, TKey> A change set with the key/value changes.
Clear()
Clears all items.
Clone(IChangeSet<TObject, TKey>)
Clones the cache from the specified changes.
Parameters
changesIChangeSet <TObject, TKey>The changes.
Lookup(TKey)
Lookup a single item using the specified key.
Parameters
keyTKeyThe key.
Returns
- Optional<TObject>
The looked up value.
Remarks
Fast indexed lookup.
Refresh()
Raises an evaluate change for all items in the cache.
Refresh(IEnumerable<TKey>)
Raises an evaluate change for the specified keys.
Parameters
keysIEnumerable<TKey>The keys to refresh.
Refresh(TKey)
Raises an evaluate change for the specified key.
Parameters
keyTKeyThe key.
Remove(IEnumerable<TKey>)
Removes the item matching the specified keys.
Parameters
keysIEnumerable<TKey>The keys.
Remove(TKey)
Removes the item matching the specified key.
Parameters
keyTKeyThe key.