Class LockFreeObservableCache<TObject, TKey>
- Namespace
- DynamicData.Cache.Internal
- Assembly
- DynamicData.dll
An observable cache which exposes an update API. Used at the root of all observable chains.
public sealed class LockFreeObservableCache<TObject, TKey> : IObservableCache<TObject, TKey>, IConnectableCache<TObject, TKey>, IDisposable where TObject : notnull where TKey : notnull
Type Parameters
TObject
The type of the object.
TKey
The type of the key.
- Inheritance
-
LockFreeObservableCache<TObject, TKey>
- Implements
-
IObservableCache<TObject, TKey>IConnectableCache<TObject, TKey>
- Extension Methods
Constructors
LockFreeObservableCache()
Initializes a new instance of the LockFreeObservableCache<TObject, TKey> class.
public LockFreeObservableCache()
LockFreeObservableCache(IObservable<IChangeSet<TObject, TKey>>)
Initializes a new instance of the LockFreeObservableCache<TObject, TKey> class.
public LockFreeObservableCache(IObservable<IChangeSet<TObject, TKey>> source)
Parameters
source
IObservable<IChangeSet<TObject, TKey>>The source.
Properties
Count
Gets the total count of cached items.
public int Count { get; }
Property Value
CountChanged
Gets a count changed observable starting with the current count.
public IObservable<int> CountChanged { get; }
Property Value
Items
Gets the Items.
public IReadOnlyList<TObject> Items { get; }
Property Value
- IReadOnlyList<TObject>
KeyValues
Gets the key value pairs.
public IReadOnlyDictionary<TKey, TObject> KeyValues { get; }
Property Value
- IReadOnlyDictionary<TKey, TObject>
Keys
Gets the keys.
public IReadOnlyList<TKey> Keys { get; }
Property Value
- IReadOnlyList<TKey>
Methods
Connect(Func<TObject, bool>?, bool)
Returns a filtered stream of cache changes preceded with the initial filtered state.
public IObservable<IChangeSet<TObject, TKey>> Connect(Func<TObject, bool>? predicate = null, bool suppressEmptyChangeSets = true)
Parameters
predicate
Func<TObject, bool>The result will be filtered using the specified predicate.
suppressEmptyChangeSets
boolBy default, empty change sets are not emitted. Set this value to false to emit empty change sets.
Returns
- IObservable<IChangeSet<TObject, TKey>>
An observable that emits the change set.
Dispose()
public void Dispose()
Edit(Action<ICacheUpdater<TObject, TKey>>)
Edits the specified edit action.
public void Edit(Action<ICacheUpdater<TObject, TKey>> editAction)
Parameters
editAction
Action<ICacheUpdater<TObject, TKey>>The edit action.
Lookup(TKey)
Lookup a single item using the specified key.
public Optional<TObject> Lookup(TKey key)
Parameters
key
TKeyThe key.
Returns
- Optional<TObject>
The looked up value.
Remarks
Fast indexed lookup.
Preview(Func<TObject, bool>?)
Returns a filtered stream of cache changes. Unlike Connect(), the returned observable is not prepended with the caches initial items.
public IObservable<IChangeSet<TObject, TKey>> Preview(Func<TObject, bool>? predicate = null)
Parameters
Returns
- IObservable<IChangeSet<TObject, TKey>>
An observable that emits the change set.
Watch(TKey)
Returns an observable of any changes which match the specified key. The sequence starts with the initial item in the cache (if there is one).
public IObservable<Change<TObject, TKey>> Watch(TKey key)
Parameters
key
TKeyThe key.
Returns
- IObservable<Change<TObject, TKey>>
An observable that emits the changes.