473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

caching/state management

I have both datatables and custom objects that are specific to a session and
need to be cached for such things as paging, sorting, etc... As far as I
can tell, there would be 2 basic ways to do
this:

1. Use session state to store these objects.
2. Use the System.Web.Caching namespace to cache the objects using a session
specific key.

So, is one of these approaches better (more efficient & scalable) than the
other or is there another approach the is best? Using the database is not a
viable option for a variety of reasons, including query speed and load...

Thanks

Jan 24 '06 #1
2 1184
They are both viable solutions, they both have advantages. Session specific
keys can be ugly and messy. I wish that there was a SessionCache that took
the wonderfulness of the cache object, and made it session-based. On the
flip side, sessions pin stuff in memory. I much prefer the cache approach,
where you aren't guaranteed it'll be there. By using weak references, the
Cache allows ASP.NET to manage it's own memory much better than the session
object does. You have to code more defensively (check if it's in the cache
first, since it might not be), but in the end it's much more powerful code.

Also, remember, Sessions scale better because you can go out of process if
you need to, cache object is always going to be per-machine. Use the
session object if you think you might need to go out of process.

Without knowing more details, I'd probably go the way of the cache.

You could built a wrapper than abstacts the implemnentation, thus letting
you switch between the two easily.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"baffled" <ba*****@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
I have both datatables and custom objects that are specific to a session
and
need to be cached for such things as paging, sorting, etc... As far as I
can tell, there would be 2 basic ways to do
this:

1. Use session state to store these objects.
2. Use the System.Web.Caching namespace to cache the objects using a
session
specific key.

So, is one of these approaches better (more efficient & scalable) than the
other or is there another approach the is best? Using the database is not
a
viable option for a variety of reasons, including query speed and load...

Thanks

Jan 24 '06 #2
It depends on the scope of the cached data. If it's a per user scope, then
you might use the session; on a per application scope, then the data cache
would be a better option. From your post, it looks like it's per-session
scope (since you mentioned the "session specific key"). In this case you
want to use the session state -- if you used the data cache and mis-handled
your expiration, then your cached object could live far beyond the scope of
the session impacting performance.

Hope this helps,

Matt Dinovo

"baffled" <ba*****@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
I have both datatables and custom objects that are specific to a session
and
need to be cached for such things as paging, sorting, etc... As far as I
can tell, there would be 2 basic ways to do
this:

1. Use session state to store these objects.
2. Use the System.Web.Caching namespace to cache the objects using a
session
specific key.

So, is one of these approaches better (more efficient & scalable) than the
other or is there another approach the is best? Using the database is not
a
viable option for a variety of reasons, including query speed and load...

Thanks

Jan 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open...
6
by: spacehopper_man | last post by:
I'm considering ditching all use of Session state in favour of Application state. This is because - from what I can work out - it will be more memory efficient for me. I have three questions:...
7
by: ask ksa | last post by:
hi, is anybody familiar with production-ready distributed/clustered cache solution for .net ? Google helped me to found some (like ncache and scale-out-state-server), but they are over-priced ...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
I'm researching what is the best way to create a generic WCF proxy wrapper that has the following requirements: 1. Remove the System.ServiceModel config section requirement for clients. We have...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
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...
0
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...
1
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.