Caching data in a web app

M

Mark

Avoiding a connection problem due to network issues is our highest priority
for one of our apps. Hence, we'd like to cache 200 records so they are
available IF a connection wasn't available. However, it's my understanding
that you can cache an object (perhaps a DataSet) for a specified amount of
time. Let's say we cache it for 5 minutes. However, consider the scenario
where a new user comes in 6 minutes after the last cache, so wouldn't the
cached object be garbage collected? What if the connection fails at that
moment? I have NO data ... which is exactly what we're trying to avoid.
How do you recommend we deal with this issue? We could cache the thing all
day, but the data will change with some frequency so we'd like to have
updates as frequently as possible too.

Thanks in advance.

Mark
 
S

Scott Allen

Hi Mark:

If it the results have to be there absolutely, positively all the
time, you might consider caching the DataSet on the web server by
saving it as an XML file on the file system.

Holding the DataSet in cache means it could be pushed out, as you
point out. You could keep it in the Application object, but this
collection would be cleared if the web application restarts for some
reason.
 
K

Kevin Spencer

Hi Mark,

You have a couple of choices. You can cache the data with no expiration, so
that it never is released. You can have it expire, and include logic that
rebuilds it when it is not there.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
H

Hermit Dave

i agree with kevin, set it to not expire and everytime it there is a change
remove the object from cache that way next request will fetch it from db and
then set the cache before returning the data.

that way you will have minimum connections to db.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top