Scheduling a Cache refresh

E

Erick

i have an asp.net application and I want to save the results of an sql
query in cache. Because the queries take 28 seconds to run (there are
twelve similar queries) I want to run it all at 4am, Place the
results in cache and use those values the rest of the day for all
users.

I have something like this

CallMe = New Caching.CacheItemRemovedCallback(AddressOf
Refresh)
Context.Cache.Insert(CacheKey, SomeObject,Nothing,
EarlyMornindDateTime), Context.Cache.NoSlidingExpiration,
Caching.CacheItemPriority.High, CallMe)

The Refresh function in the CallMe object doesn't run when the time
expires. It runs only if a user request the value in the cache then it
checks the expiry time and then fires the callback function. Cache is
refreshed by the first user to acces cache not automatical by the
system at 4am

Just a reminder. I cannot run a console program or a service. The IIS
server is locked down. It has to be an asp.net based solution within
the same application. Version 1.1 of framework is used.

Some one out there must have had similar problems to this

Any Help appreciated
 
P

Peter Rilling

IIS most likely requires a user (of sorts) to interact with an app. The
server is locked down, but what about running a task from a different
machine. In this case, what you could do is to create a webservice which
has a command to refresh the cache. Then your scheduled app could call the
webservice and invoke the action. Or this program could use an
HttpWebRequest to simply access any page on the site, then the site would
have the code to determine the time and run update the cache.
 
B

bruce barker

if your server is locked down, you need to also check the asp.net timeout,
as this will normally be set. if you site has no activity for a given amount
of time, then the appdomain is unloaded, and you lose all cache items.
usually this means the first person to hit the morning pay the startup cost
(compile, domain load, etc)

-- bruce (sqlwork.com)


| i have an asp.net application and I want to save the results of an sql
| query in cache. Because the queries take 28 seconds to run (there are
| twelve similar queries) I want to run it all at 4am, Place the
| results in cache and use those values the rest of the day for all
| users.
|
| I have something like this
|
| CallMe = New Caching.CacheItemRemovedCallback(AddressOf
| Refresh)
| Context.Cache.Insert(CacheKey, SomeObject,Nothing,
| EarlyMornindDateTime), Context.Cache.NoSlidingExpiration,
| Caching.CacheItemPriority.High, CallMe)
|
| The Refresh function in the CallMe object doesn't run when the time
| expires. It runs only if a user request the value in the cache then it
| checks the expiry time and then fires the callback function. Cache is
| refreshed by the first user to acces cache not automatical by the
| system at 4am
|
| Just a reminder. I cannot run a console program or a service. The IIS
| server is locked down. It has to be an asp.net based solution within
| the same application. Version 1.1 of framework is used.
|
| Some one out there must have had similar problems to this
|
| Any Help appreciated
 
E

Erick

Peter Rilling said:
IIS most likely requires a user (of sorts) to interact with an app. The
server is locked down, but what about running a task from a different
machine. In this case, what you could do is to create a webservice which
has a command to refresh the cache. Then your scheduled app could call the
webservice and invoke the action. Or this program could use an
HttpWebRequest to simply access any page on the site, then the site would
have the code to determine the time and run update the cache.


No i can't run a task from a different machine. This is the IIS
production server. It won't let a task running on a different machine
attache to an applicaton's cache on it. The entire operation must run
in it's own vurtual web site. There are many other application on
this server belonging to many different business groups. To keep them
all from interfering we are locked into our own vurtual web site and
can't get out or in. No web servers are allowed on this site as yet
anyway.

So far I am trying to get a new thread to run during application start
in the global asa that will sleep for 24 hours and then wake up and
call the cache refresh.

Thanks for the help
 
E

Erick

Thanks bruce I will look into it.
I have control over the virtual web site but not much else on the
server.

Currently looking at using a new thread to sleep for 24 hours and then
refresh the cache. Not sure how long it will last there. But we will
check it each time a user requests data ..so some may get a very long
wait.

Josef
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top