开发者

Classic ASP, application variables, refreshing

开发者 https://www.devze.com 2022-12-16 21:00 出处:网络
I have an application variable which is populated onstart (in this case it is 开发者_开发知识库an array).Ideally I need to rebuild this array every 3 hours, what is the best way of going about this?

I have an application variable which is populated onstart (in this case it is 开发者_开发知识库an array). Ideally I need to rebuild this array every 3 hours, what is the best way of going about this?

Thanks, R.


Save the time you last refreshed the variable contents.

On every request, check the current time against the saved time. If there's a three hour difference, lock and refresh the variable.

As long as there are no requests, the variable also needs no refreshing.


If your application variable must remain "in process" with the rest of the site's code, the way suggested by Tomalak may be your only way of achieving this.

However, if it's possible that the application variable could effectively reside "out of process" of the website's ASP code (although still accessible by it), you may be able to utilise a different (and perhaps slightly better) approach.

Please see "ASP 101: Getting Scripts to Run on a Schedule" for the details.

Tomalak's method is effectively Method 1 in the article, whilst Method's 2 & 3 offer different ways of achieving what is effectively something happening on a schedule, and avoid the potentially redundant checking with every HTTP request.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号