Groups | Blog | Home
all groups > asp.net caching > january 2005 >

asp.net caching : Question/Advice on updating Cache


Keith F.
1/20/2005 3:05:01 PM
Hi,
I'm trying to implement caching for an ASP.NET web app, to reduce calls to
our backend database (sql server). The object I want to cache is a simple
data table.
The tricky part is that throughout the day, I need to be able to update
individual records. The updates are infrequent. Each record will probably be
updated once sometime during the day. But this table will be read thousands
of times. So caching will save thousands of database calls.

I've read about using the ReaderWriterLock class at the following site:
http://msdn.microsoft.com/msdnmag/issues/05/02/BasicInstincts/default.aspx

I've experimented with creating a custom class, I'll call it the
CacheManager, that will be the "gate-keeper" for my data table cache object
and use the ReaderWriterLock class to make sure only one update happens at a
time.
In order for this to work, I've found that I have to Cache an instance of my
CacheManager, and all requests to read or update the data table cache object,
go through that instance of CacheManager.

In some basic testing using multiple browser sessions, this approach seems
to work. But I want to make sure this will work with a hundred or more users.

Does this seem like the right approach, or is there a better approach to
accomplish this?

I would appreciate any suggestions/advice that you might have.

Thanks,
Keith F
Geir Aamodt
2/21/2005 6:41:39 PM
Keith,

have you been looking at or using the ASP.NET Cache object?

This Caching functionality provides you with all the functionality you need.

Look here:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcacheapis.asp
for more details about the Cache object.

To try to answer your questions without any knowledge about your
solution/code/design etc.
is impossible, but the logic of using an CacheManager as front-end and then
utilize the ASP.NET
Cache object as back-end, is a very good idea I have used in several
projects.

--

Best regards,
Geir Aamodt
geir.aamodt(AT)bekk.no


[quoted text, click to view]

AddThis Social Bookmark Button