Optimizations
This commit is contained in:
@@ -15,6 +15,7 @@ namespace MarketData.Cache
|
||||
{
|
||||
private Dictionary<String,PricesByDate> priceCache=new Dictionary<String,PricesByDate>();
|
||||
private static LocalPriceCache instance=null;
|
||||
private DateTime latestDate = Utility.Epoch;
|
||||
private Thread cacheMonitorThread=null;
|
||||
private volatile bool threadRun=true;
|
||||
private int cacheCycle=300000;
|
||||
@@ -30,7 +31,8 @@ namespace MarketData.Cache
|
||||
{
|
||||
lock(thisLock)
|
||||
{
|
||||
priceCache=new Dictionary<String,PricesByDate>();
|
||||
priceCache=new Dictionary<String,PricesByDate>();
|
||||
RefreshLatestDate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,18 +57,38 @@ namespace MarketData.Cache
|
||||
{
|
||||
lock(typeof(LocalPriceCache))
|
||||
{
|
||||
if(null==instance)instance=new LocalPriceCache();
|
||||
if(null==instance)
|
||||
{
|
||||
instance=new LocalPriceCache();
|
||||
instance.RefreshLatestDate();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshLatestDate()
|
||||
{
|
||||
lock(typeof(LocalPriceCache))
|
||||
{
|
||||
latestDate=PricingDA.GetLatestDate();
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime GetLatestDate()
|
||||
{
|
||||
lock(typeof(LocalPriceCache))
|
||||
{
|
||||
return latestDate;
|
||||
}
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
lock(typeof(LocalPriceCache))
|
||||
{
|
||||
List<String> symbols=new List<String>(priceCache.Keys);
|
||||
Dictionary<String, DateTime> maxDbDates = PricingDA.GetLatestDates(symbols);
|
||||
|
||||
RefreshLatestDate();
|
||||
foreach(String symbol in symbols)
|
||||
{
|
||||
PricesByDate symbolPrices=priceCache[symbol];
|
||||
|
||||
Reference in New Issue
Block a user