cache tweaks

This commit is contained in:
Vincent Cloutier 2023-03-17 15:10:53 -04:00
parent 6dc006bc66
commit 4dd071abe2
4 changed files with 6 additions and 4 deletions

View File

@ -15,6 +15,7 @@
public int FailingFollowerCleanUpThreshold { get; set; } = -1;
public int UserCacheCapacity { get; set; }
public int TweetCacheCapacity { get; set; } = 20_000;
public int ParallelTwitterRequests { get; set; } = 10;
public int ParallelFediversePosts { get; set; } = 10;
}

View File

@ -56,7 +56,9 @@ namespace BirdsiteLive.Pipeline
retrieveFollowersBlock.LinkTo(retrieveFollowersBufferBlock, new DataflowLinkOptions { PropagateCompletion = true });
retrieveFollowersBufferBlock.LinkTo(sendTweetsToFollowersBlock, new DataflowLinkOptions { PropagateCompletion = true });
// Launch twitter user retriever
// Launch twitter user retriever after a little delay
// to give time for the Tweet cache to fill
await Task.Delay(30 * 1000, ct);
var retrieveTwitterAccountsTask = _retrieveTwitterAccountsProcessor.GetTwitterUsersAsync(twitterUserToRefreshBufferBlock, ct);
// Wait

View File

@ -18,7 +18,6 @@ namespace BirdsiteLive.Twitter
private readonly MemoryCache _tweetCache;
private readonly MemoryCacheEntryOptions _cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(10000)//Size amount
//Priority on removing when reaching size limit (memory pressure)
.SetPriority(CacheItemPriority.Low)
// Keep in cache for this time, reset time if accessed.
@ -33,7 +32,7 @@ namespace BirdsiteLive.Twitter
_tweetCache = new MemoryCache(new MemoryCacheOptions()
{
SizeLimit = 10000 //TODO make this use number of entries in db
SizeLimit = settings.TweetCacheCapacity,
});
}
#endregion

View File

@ -16,7 +16,7 @@ namespace BirdsiteLive.Pipeline.Tests
public async Task ExecuteAsync_Test()
{
#region Stubs
var ct = new CancellationTokenSource(10);
var ct = new CancellationTokenSource(100 * 1000);
#endregion
#region Mocks