Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/GitHub.App/Caches/CacheIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static IObservable<CacheIndex> AddAndSaveToIndex(IBlobCache cache, string
Guard.ArgumentNotNull(item, nameof(item));

return cache.GetOrCreateObject(indexKey, () => Create(indexKey))
.Select(x => x.IndexKey == null ? Create(indexKey) : x)
.Do(index =>
{
var k = string.Format(CultureInfo.InvariantCulture, "{0}|{1}", index.IndexKey, item.Key);
Expand Down
7 changes: 6 additions & 1 deletion src/GitHub.App/Extensions/AkavacheExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ static IObservable<T> GetAndFetchLatestFromIndex<T>(this IBlobCache This,
bool shouldInvalidateOnError = false)
where T : CacheItem
{
var idx = Observable.Defer(() => This.GetOrCreateObject(key, () => CacheIndex.Create(key))).Replay().RefCount();
var idx = Observable.Defer(() => This
.GetOrCreateObject(key, () => CacheIndex.Create(key)))
.Select(x => x.IndexKey == null ? CacheIndex.Create(key) : x)
.Replay()
.RefCount();


var fetch = idx
Expand Down Expand Up @@ -264,6 +268,7 @@ public static IObservable<T> PutAndUpdateIndex<T>(this IBlobCache blobCache,
{
var absoluteExpiration = blobCache.Scheduler.Now + maxCacheDuration;
return blobCache.GetOrCreateObject(key, () => CacheIndex.Create(key))
.Select(x => x.IndexKey == null ? CacheIndex.Create(key) : x)
.SelectMany(index => fetchFunc()
.Catch<T, Exception>(Observable.Throw<T>)
.SelectMany(x => x.Save<T>(blobCache, key, absoluteExpiration))
Expand Down