C # / ASP.NET / SQL Server - running a query once a day

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.

+5
source share
7 answers

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.

+3
source

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)

+1
source

Cache 24 ? : -)

+1

-: ; , , , , . , , , . , SQL Server , . , , , - , 24 .

, .

  • VBScript () PowerShell script, , , aspx, ascx HTML , -. script - ( , ).

  • Windows. . , - .., .

, , , , HTML. ASP.NET . MVC, Razor script .

, , . , .

+1

, - , - . , .

- . , . , . , . 24 . , , , - ( , , ), , , , ".

0
  • ASP.NET. , , DateTime . , DateTime.Now - > 24h → ( - )

  • - , -

0

, . , , , , 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;
        }
    }
0

All Articles