cache tweaks
This commit is contained in:
parent
6dc006bc66
commit
4dd071abe2
4 changed files with 6 additions and 4 deletions
|
@ -15,6 +15,7 @@
|
||||||
public int FailingFollowerCleanUpThreshold { get; set; } = -1;
|
public int FailingFollowerCleanUpThreshold { get; set; } = -1;
|
||||||
|
|
||||||
public int UserCacheCapacity { get; set; }
|
public int UserCacheCapacity { get; set; }
|
||||||
|
public int TweetCacheCapacity { get; set; } = 20_000;
|
||||||
public int ParallelTwitterRequests { get; set; } = 10;
|
public int ParallelTwitterRequests { get; set; } = 10;
|
||||||
public int ParallelFediversePosts { get; set; } = 10;
|
public int ParallelFediversePosts { get; set; } = 10;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,9 @@ namespace BirdsiteLive.Pipeline
|
||||||
retrieveFollowersBlock.LinkTo(retrieveFollowersBufferBlock, new DataflowLinkOptions { PropagateCompletion = true });
|
retrieveFollowersBlock.LinkTo(retrieveFollowersBufferBlock, new DataflowLinkOptions { PropagateCompletion = true });
|
||||||
retrieveFollowersBufferBlock.LinkTo(sendTweetsToFollowersBlock, 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);
|
var retrieveTwitterAccountsTask = _retrieveTwitterAccountsProcessor.GetTwitterUsersAsync(twitterUserToRefreshBufferBlock, ct);
|
||||||
|
|
||||||
// Wait
|
// Wait
|
||||||
|
|
|
@ -18,7 +18,6 @@ namespace BirdsiteLive.Twitter
|
||||||
|
|
||||||
private readonly MemoryCache _tweetCache;
|
private readonly MemoryCache _tweetCache;
|
||||||
private readonly MemoryCacheEntryOptions _cacheEntryOptions = new MemoryCacheEntryOptions()
|
private readonly MemoryCacheEntryOptions _cacheEntryOptions = new MemoryCacheEntryOptions()
|
||||||
.SetSize(10000)//Size amount
|
|
||||||
//Priority on removing when reaching size limit (memory pressure)
|
//Priority on removing when reaching size limit (memory pressure)
|
||||||
.SetPriority(CacheItemPriority.Low)
|
.SetPriority(CacheItemPriority.Low)
|
||||||
// Keep in cache for this time, reset time if accessed.
|
// Keep in cache for this time, reset time if accessed.
|
||||||
|
@ -33,7 +32,7 @@ namespace BirdsiteLive.Twitter
|
||||||
|
|
||||||
_tweetCache = new MemoryCache(new MemoryCacheOptions()
|
_tweetCache = new MemoryCache(new MemoryCacheOptions()
|
||||||
{
|
{
|
||||||
SizeLimit = 10000 //TODO make this use number of entries in db
|
SizeLimit = settings.TweetCacheCapacity,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace BirdsiteLive.Pipeline.Tests
|
||||||
public async Task ExecuteAsync_Test()
|
public async Task ExecuteAsync_Test()
|
||||||
{
|
{
|
||||||
#region Stubs
|
#region Stubs
|
||||||
var ct = new CancellationTokenSource(10);
|
var ct = new CancellationTokenSource(100 * 1000);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Mocks
|
#region Mocks
|
||||||
|
|
Loading…
Add table
Reference in a new issue