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
TObject
The value of the cache.
TKey
The 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
data
Dictionary<TKey, TObject>Data to populate the cache with.
ChangeAwareCache(int)
Initializes a new instance of the ChangeAwareCache<TObject, TKey> class.
Parameters
capacity
intThe 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
item
TObjectThe item to add.
key
TKeyThe key to add.
AddOrUpdate(TObject, TKey)
Adds or updates the item using the specified key.
Parameters
item
TObjectThe item.
key
TKeyThe 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
changes
IChangeSet <TObject, TKey>The changes.
Lookup(TKey)
Lookup a single item using the specified key.
Parameters
key
TKeyThe 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
keys
IEnumerable<TKey>The keys to refresh.
Refresh(TKey)
Raises an evaluate change for the specified key.
Parameters
key
TKeyThe key.
Remove(IEnumerable<TKey>)
Removes the item matching the specified keys.
Parameters
keys
IEnumerable<TKey>The keys.
Remove(TKey)
Removes the item matching the specified key.
Parameters
key
TKeyThe key.