/// <summary> /// Remove a cache entry from the <see cref="IMemoryCache"/> with the key /// generated by the key factory function. /// </summary> /// <typeparam name="TSource">The type of the value.</typeparam> /// <param name="observable">The parent observable.</param> /// <param name="keyFactory">The key factory function.</param> /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns> public static IProviderObservable <TSource> RemoveMemoryCacheEntry <TSource>( this IProviderObservable <TSource> observable, Func <TSource, object> keyFactory) => observable.Do(s => { var memoryCache = observable.ServiceProvider.GetService <IMemoryCache>(); var key = keyFactory(s); memoryCache.Remove(key); });