Using cacheing??

G

Guest

I’m researching the idea of using caching in my application. And I wanted to
get other people thoughts that have used it with .NET 2.0. Below is an
explanation of the current process:

I have an application with several web pages. When any of these pages is
first loaded, it retrieves the information from SQL and stores the
information in a DataSet. This DataSet is then converted to a Session
variable so that it can be used over and over without the need to reconnect
to the database to refresh the data. The only time connections to SQL are
made is when the user requests to DELETE or UPDATE the physical records. Once
the delete/update is complete, I convert the Session variable back to a
dataset and perform the same action on the dataset. Next I rebind the dataset
back to the control and redisplay the page.

All works great and it is fast. But it takes a lot of memory to store those
datasets for each user session. Not to mention that if user(A) makes a change
to a record, and user (B) is view the same record, b/c they are session
variables, user (B) will never see user (A) changes.

So I wanted to try using disk caching where user (A) requests a record, it
gets cached on the server hard drive. SQL update and deletes happen as they
do now, but I update the cache instead of a dataset in memory.

If user (B) accesses the same record, and this record is already in cache
from another user, it reads the cache instead of connecting to SQL to issue
the SELECT statements. This cache would need to reside on the drive for say
24 hrs.

All this to say, have any of you done anything similar? What are thing
things I should watch out for? What’s a good resource to get started using
this method in C#. I know disk I/O is slower then memory, but its faster then
connecting to SQL every time to refresh the data.
 
M

Michael Nemtsev

Hello JP,

DataSet is fat object, and when your are gonna used it widely + serializing
it the memory consumption for DataSet may be incremented in 3 times
So, why not to store more simple structures, if u really woried about memory?

About storing - how do you gonna do this? have any solutions?
To make it more challenge - consider web-farm scenario, where the next request
maybe processed by the next node, where is your cache not available. In this
case your need to use some realization for reliable clastered cache, as I
described there http://laflour.spaces.live.com/blog/cns!7575E2FFC19135B4!355.entry

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

J> I’m researching the idea of using caching in my application. And I
J> wanted to get other people thoughts that have used it with .NET 2.0.
J> Below is an explanation of the current process:
J>
J> I have an application with several web pages. When any of these pages
J> is first loaded, it retrieves the information from SQL and stores the
J> information in a DataSet. This DataSet is then converted to a Session
J> variable so that it can be used over and over without the need to
J> reconnect to the database to refresh the data. The only time
J> connections to SQL are made is when the user requests to DELETE or
J> UPDATE the physical records. Once the delete/update is complete, I
J> convert the Session variable back to a dataset and perform the same
J> action on the dataset. Next I rebind the dataset back to the control
J> and redisplay the page.
J>
J> All works great and it is fast. But it takes a lot of memory to store
J> those datasets for each user session. Not to mention that if user(A)
J> makes a change to a record, and user (B) is view the same record, b/c
J> they are session variables, user (B) will never see user (A) changes.
J>
J> So I wanted to try using disk caching where user (A) requests a
J> record, it gets cached on the server hard drive. SQL update and
J> deletes happen as they do now, but I update the cache instead of a
J> dataset in memory.
J>
J> If user (B) accesses the same record, and this record is already in
J> cache from another user, it reads the cache instead of connecting to
J> SQL to issue the SELECT statements. This cache would need to reside
J> on the drive for say 24 hrs.
J>
J> All this to say, have any of you done anything similar? What are
J> thing things I should watch out for? What’s a good resource to get
J> started using this method in C#. I know disk I/O is slower then
J> memory, but its faster then connecting to SQL every time to refresh
J> the data.
J>
 

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

Top