You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unlike ExpireAfter the LimitSizeTo does not notify the subscribers on deletion, only on completion.
I listen on a Observable and to keep track of it (like history) I put it into a ObservableChangeSet and persist it. Basically a persistable history of an Observable. The Observable I listen runs forever. But the LimitSizeTo never notify the subscriber when deletion occurs only when the ISourceCache completes. So I cannot delete the oldest objects from the database to keep the memory/disk size constant.
The code where it fails for me:
public IObservable<IChangeSet<TObject, TKey>> CreatePersistenceObservableChangeSet<TObject, TKey>(
IObservable<TObject> fromObservable,
Func<TObject, TKey> keySelector,
int sizeLimit = 0)
{
return ObservableChangeSet.Create(cache =>
{
var collection = GetCollection<TObject>();
var compositeDisposable = new CompositeDisposable();
// initial load from database after restart
cache.AddOrUpdate(collection.FindAll());
if (sizeLimit > 0)
{
cache.LimitSizeTo(sizeLimit)
.Subscribe(items =>
{
foreach (var keyValuePair in items)
{
collection.Delete(keyValuePair.Key);
}
})
.DisposeWith(compositeDisposable);
}
fromObservable.Subscribe(item =>
{
collection.Upsert(keySelector(item), item);
cache.AddOrUpdate(item);
})
.DisposeWith(compositeDisposable);
return compositeDisposable;
}, keySelector);
}
The text was updated successfully, but these errors were encountered:
Unlike
ExpireAfter
theLimitSizeTo
does not notify the subscribers on deletion, only on completion.I listen on a
Observable
and to keep track of it (like history) I put it into a ObservableChangeSet and persist it. Basically a persistable history of anObservable
. TheObservable
I listen runs forever. But theLimitSizeTo
never notify the subscriber when deletion occurs only when theISourceCache
completes. So I cannot delete the oldest objects from the database to keep the memory/disk size constant.The code where it fails for me:
The text was updated successfully, but these errors were encountered: