Daily + GLPriceCache optimizations
Some checks failed
Build .NET Project / build (push) Has been cancelled

This commit is contained in:
2026-02-27 20:43:41 -05:00
parent e633235407
commit af499ff037
2 changed files with 23 additions and 22 deletions

View File

@@ -17,9 +17,25 @@ namespace MarketData.Cache
private static GLPriceCache instance = null;
// -- Disposal -------------------------------------------------------------
private volatile bool disposed = false;
private int refreshInProgress = 0;
// -- State ----------------------------------------------------------------
private readonly Dictionary<string, PricesByDate> priceCache = new Dictionary<string, PricesByDate>();
private readonly ConcurrentDictionary<string, object> symbolFetchLocks = new ConcurrentDictionary<string, object>();
private readonly object cacheLock = new object();
private DateTime latestDate = Utility.Epoch;
// -- Background refresh ---------------------------------------------------
private readonly TimeSpan cacheCycle = TimeSpan.FromMinutes(5);
private Timer refreshTimer = null;
private int tickCount = 0;
// private const int evictionTickInterval = 12; // every 12 ticks x 5 min = 1 hour
private const int evictionTickInterval = 144; // every 144 ticks x 5 min interval length = 12 hour. (144 intervals *5 minutes )/60 minutes = 12 hours
// -- Parallelism ----------------------------------------------------------
private static readonly int maxParallelDbCalls = ResolveMaxParallelDbCalls();
/// <summary>
///
/// </summary>
@@ -33,21 +49,6 @@ namespace MarketData.Cache
}
}
// -- State ----------------------------------------------------------------
private readonly Dictionary<string, PricesByDate> priceCache = new Dictionary<string, PricesByDate>();
private readonly ConcurrentDictionary<string, object> symbolFetchLocks = new ConcurrentDictionary<string, object>();
private readonly object cacheLock = new object();
private DateTime latestDate = Utility.Epoch;
// -- Background refresh ---------------------------------------------------
private readonly TimeSpan cacheCycle = TimeSpan.FromMinutes(5);
private Timer refreshTimer = null;
private int tickCount = 0;
private const int evictionTickInterval = 12; // every 12 ticks x 5 min = 1 hour
// -- Parallelism ----------------------------------------------------------
private static readonly int maxParallelDbCalls = ResolveMaxParallelDbCalls();
private static int ResolveMaxParallelDbCalls()
{
return Math.Min(Math.Max(1, Environment.ProcessorCount) * 3, 32);