I am going to make a progress bar for the donations page on the website that I am launching. I want the progress bar to be updated once a day, and not on every page load, as usual.
What options do I have here to capture the current donation SUM and put it, possibly in a text file for an aspx page, to read, rather than query the database every time.?
Hope this makes sense.
Another option is to use caching and set the cache only for 24 hours. Data is then retrieved and cached, and the cached version is maintained all day.
I would just run a SUM query in the database every time. If you do not expect millions of line inserts per day, this will be negligible. (Providing indexes on your database table)
Cache 24 ? : -)
-: ; , , , , . , , , . , SQL Server , . , , , - , 24 .
, .
VBScript () PowerShell script, , , aspx, ascx HTML , -. script - ( , ).
Windows. . , - .., .
, , , , HTML. ASP.NET . MVC, Razor script .
, , . , .
, - , - . , .
- . , . , . , . 24 . , , , - ( , , ), , , , ".
ASP.NET. , , DateTime . , DateTime.Now - > 24h → ( - )
- , -
, . , , , , 24 . , . . , , .
- :
int ProgressValue { get { int? Value = Cache["ProgressValue"] as int?; if (Value == null) { //Set expiration time to 6 AM tomorrow. DateTime ExpTime = DateTime.Now.Date.AddDays(1).AddHours(6); Value = GetValueFromDB(); Cache.Insert("ProgressValue", Value, null, ExpTime, System.Web.Caching.Cache.NoSlidingExpiration); } return (int)Value; } }