Hi-
I am having a hard time decided where I should be implementing my Cache
code. I store most of the DataSet's that I need in the Cache. I was doing
it in the bind method of my pages, but then I thought it would be cleaner to
maybe at the Cache code directly in the DAL. So, for example I might have a
DAL method to get products that looks like this:
public DataSet GetProducts()
{
if(Cache["prodData"])
{
return (DataSet)Cache["prodData"];
}
else
{
DataSet dsBuff;
//.... code to get stuff from the DB - fill the dsBuff with it
Cache["prodData"] = dsBuff;
return dsBuff;
}
}
(that was not real code, I just typed it, so if there are typos.. please
disgregard)
I'm curious if this is how you guys are doing things? Is there anything
wrong with doing it this way?
your thoughts please...
- Steve 5 3203
You're probably better off to implement caching outside the DAL. If you
cache in the DAL, what happens if you need to change the caching mechanism.
You then have to verify that all the dependant functions behave properly,
not to mention you then end up with a very specific set of DAL functions.
You could implement a caching engine to call the DAL, which would unify your
caching functions and at the same time give you the flexibility to having
cached and non-cached data (or cached data that may be depednent on
different events/files/functions) from one clean DAL.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"sklett" <as**@fkd.com> wrote in message
news:ew***************@TK2MSFTNGP12.phx.gbl... Hi-
I am having a hard time decided where I should be implementing my Cache code. I store most of the DataSet's that I need in the Cache. I was
doing it in the bind method of my pages, but then I thought it would be cleaner
to maybe at the Cache code directly in the DAL. So, for example I might have
a DAL method to get products that looks like this:
public DataSet GetProducts() { if(Cache["prodData"]) { return (DataSet)Cache["prodData"]; } else { DataSet dsBuff; //.... code to get stuff from the DB - fill the dsBuff with it
Cache["prodData"] = dsBuff; return dsBuff; } }
(that was not real code, I just typed it, so if there are typos.. please disgregard) I'm curious if this is how you guys are doing things? Is there anything wrong with doing it this way?
your thoughts please...
- Steve
General rule of thumb: Cache your data at the scope in which it is needed.
In other words, if, for example, you have data that is not specific to any
user, but is used in many pages, cache it at the Application level. If it is
specific to a user, but used across many pages, cache it at the Session
level. If it is only used on a single Paage, either don't cache it, or cache
it in ViewState.
The principle here is to minimize memory usage, and not persist any data
that is no longer needed.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"sklett" <as**@fkd.com> wrote in message
news:ew*************@TK2MSFTNGP12.phx.gbl... Hi-
I am having a hard time decided where I should be implementing my Cache code. I store most of the DataSet's that I need in the Cache. I was
doing it in the bind method of my pages, but then I thought it would be cleaner
to maybe at the Cache code directly in the DAL. So, for example I might have
a DAL method to get products that looks like this:
public DataSet GetProducts() { if(Cache["prodData"]) { return (DataSet)Cache["prodData"]; } else { DataSet dsBuff; //.... code to get stuff from the DB - fill the dsBuff with it
Cache["prodData"] = dsBuff; return dsBuff; } }
(that was not real code, I just typed it, so if there are typos.. please disgregard) I'm curious if this is how you guys are doing things? Is there anything wrong with doing it this way?
your thoughts please...
- Steve
General rule of thumb: Cache your data at the scope in which it is needed.
In other words, if, for example, you have data that is not specific to any
user, but is used in many pages, cache it at the Application level. If it is
specific to a user, but used across many pages, cache it at the Session
level. If it is only used on a single Paage, either don't cache it, or cache
it in ViewState.
The principle here is to minimize memory usage, and not persist any data
that is no longer needed.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"sklett" <as**@fkd.com> wrote in message
news:ew*************@TK2MSFTNGP12.phx.gbl... Hi-
I am having a hard time decided where I should be implementing my Cache code. I store most of the DataSet's that I need in the Cache. I was
doing it in the bind method of my pages, but then I thought it would be cleaner
to maybe at the Cache code directly in the DAL. So, for example I might have
a DAL method to get products that looks like this:
public DataSet GetProducts() { if(Cache["prodData"]) { return (DataSet)Cache["prodData"]; } else { DataSet dsBuff; //.... code to get stuff from the DB - fill the dsBuff with it
Cache["prodData"] = dsBuff; return dsBuff; } }
(that was not real code, I just typed it, so if there are typos.. please disgregard) I'm curious if this is how you guys are doing things? Is there anything wrong with doing it this way?
your thoughts please...
- Steve
What I have been doing is storing all the product data (the company has 10
products, so there is not much) in a DataSet, I then cache that. When a
user chooses a product from the product listing page, I use the Select
method of a table in the DataSet to get just the data I want.
I made the site's admin all web based, when a product is added or modified,
I empty the cache, then the next time product data is needed, I hit the DB
and fill the cache again.
I hear what you are saying though. I'm just starting to have a hard time
decided if I need to even cache stuff, the traffic is so low, maybe it would
be cleaner to hit the DB each time.
Need to think and plan more ;)
Thanks both of you for the responses, they are valuable.
-Steve
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:e7**************@TK2MSFTNGP09.phx.gbl... General rule of thumb: Cache your data at the scope in which it is needed. In other words, if, for example, you have data that is not specific to any user, but is used in many pages, cache it at the Application level. If it
is specific to a user, but used across many pages, cache it at the Session level. If it is only used on a single Paage, either don't cache it, or
cache it in ViewState.
The principle here is to minimize memory usage, and not persist any data that is no longer needed.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"sklett" <as**@fkd.com> wrote in message news:ew*************@TK2MSFTNGP12.phx.gbl... Hi-
I am having a hard time decided where I should be implementing my Cache code. I store most of the DataSet's that I need in the Cache. I was doing it in the bind method of my pages, but then I thought it would be
cleaner to maybe at the Cache code directly in the DAL. So, for example I might
have a DAL method to get products that looks like this:
public DataSet GetProducts() { if(Cache["prodData"]) { return (DataSet)Cache["prodData"]; } else { DataSet dsBuff; //.... code to get stuff from the DB - fill the dsBuff with it
Cache["prodData"] = dsBuff; return dsBuff; } }
(that was not real code, I just typed it, so if there are typos.. please disgregard) I'm curious if this is how you guys are doing things? Is there anything wrong with doing it this way?
your thoughts please...
- Steve
What I have been doing is storing all the product data (the company has 10
products, so there is not much) in a DataSet, I then cache that. When a
user chooses a product from the product listing page, I use the Select
method of a table in the DataSet to get just the data I want.
I made the site's admin all web based, when a product is added or modified,
I empty the cache, then the next time product data is needed, I hit the DB
and fill the cache again.
I hear what you are saying though. I'm just starting to have a hard time
decided if I need to even cache stuff, the traffic is so low, maybe it would
be cleaner to hit the DB each time.
Need to think and plan more ;)
Thanks both of you for the responses, they are valuable.
-Steve
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:e7**************@TK2MSFTNGP09.phx.gbl... General rule of thumb: Cache your data at the scope in which it is needed. In other words, if, for example, you have data that is not specific to any user, but is used in many pages, cache it at the Application level. If it
is specific to a user, but used across many pages, cache it at the Session level. If it is only used on a single Paage, either don't cache it, or
cache it in ViewState.
The principle here is to minimize memory usage, and not persist any data that is no longer needed.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"sklett" <as**@fkd.com> wrote in message news:ew*************@TK2MSFTNGP12.phx.gbl... Hi-
I am having a hard time decided where I should be implementing my Cache code. I store most of the DataSet's that I need in the Cache. I was doing it in the bind method of my pages, but then I thought it would be
cleaner to maybe at the Cache code directly in the DAL. So, for example I might
have a DAL method to get products that looks like this:
public DataSet GetProducts() { if(Cache["prodData"]) { return (DataSet)Cache["prodData"]; } else { DataSet dsBuff; //.... code to get stuff from the DB - fill the dsBuff with it
Cache["prodData"] = dsBuff; return dsBuff; } }
(that was not real code, I just typed it, so if there are typos.. please disgregard) I'm curious if this is how you guys are doing things? Is there anything wrong with doing it this way?
your thoughts please...
- Steve
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tom.PesterDELETETHISSS |
last post by:
Hi,
I think this question requires an in depth understanding of how a browser
cache works. I hope I can reach an expert here.
I may have found a quirk in the asp.net documentation or I don't...
|
by: MilanB |
last post by:
Hello
Is it possible to cache page fragment (in UserControl), and not a whole page
on client side?
Thanks
|
by: Mark |
last post by:
Hello.
I am looking for a way to download and cache a web page that the user has
not yet requested, and write the web page to the browser cache without
displaying it. My intention is to improve...
|
by: EagleRed |
last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some
pages that must not be cached on the client. In ASP.NET 1.1 I achieved this
using metatags:
<meta...
|
by: Stan SR |
last post by:
Hi,
Some newbie questions.. :-)
First, what is the namespace to use for the Cache class ?
When I use this bit of code I get an error
if (Cache==null) Cache.Insert("myUserList",userlist);...
|
by: Peter Bremer |
last post by:
Hi all,
I've got a form which lists all members of a club, with checkboxes to
select them. The form offers functions to delete selected members,
send email, etc.
Now I want write some code to...
|
by: =?Utf-8?B?bGl1eGluZmVpaHU=?= |
last post by:
Hi,
I use post way realization page postback this am must,How realizesunder the
post way controls postback continuously to be unable to findthe solution the
method to hope can obtain master's help...
|
by: amit sinha |
last post by:
I did developed a code in VS2005 aspx file which opens pop up window
on button click javascript window.showModalDialog(popwin.aspx?
cCODE='cd',winprop)
Now as popwin.aspx take long time to...
|
by: marconline |
last post by:
Hi everyone and thanks for your help. My web form is formed by a master page, which contains some web user controls. The same web form contains other web user controls.
This page is very slow....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |