PC Review


Reply
Thread Tools Rate Thread

Can I cache a DataTable in a Session object?

 
 
mark4asp
Guest
Posts: n/a
 
      7th Jun 2007
Can I cache a DataTable (or alternative GridView Datasource) in a
Session object?

.... and does the following scenario present itself as an occaison when
I could get away with doing so?

In an Asp.Net 2.0 app. I have a search results page. The results are
diplayed in a GridView with paging and sorting. In would prefer to get
all the data and do the paging/sorting in memory rather than adding to
the complexity of the T-SQL. It's not so much the paging that bothers
me as the sorting (that would be awful - I'd have to put the raw
results in a table variable first, then query the table variable to
get the paged/sorted results).

On any one day there are only about 100 clients who would use this web-
site (not concurrently). The site shares a server with an even less
busy site.

Q1: Am I right in thinking that this data should not be cached in the
Data Cache because each client will have entirely different search
results. (For instance, if two clients use the search page at the same
time that will lead to inconsistenty. - as the second client's data is
cached in the same Cache object as the first.)

Q2: Will it be possible to cache the DataSource for the GridView as
Session object instead? (assuming the above problems with the Data
Cache)

Q3: If I cache in the Session, apart from destroying the session
object (i.e the cached data) on leaving the page - are there any other
major considerations?

Q4: Would the DataSource need to be serializable for it to be storeded
as a session object?.

 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      7th Jun 2007
On Jun 7, 2:08 pm, mark4asp <mark4...@gmail.com> wrote:
> Q1: Am I right in thinking that this data should not be cached in the
> Data Cache because each client will have entirely different search
> results. (For instance, if two clients use the search page at the same
> time that will lead to inconsistenty. - as the second client's data is
> cached in the same Cache object as the first.)


Yes, Cache is available to all users


> Q2: Will it be possible to cache the DataSource for the GridView as
> Session object instead? (assuming the above problems with the Data
> Cache)


Yes


> Q3: If I cache in the Session, apart from destroying the session
> object (i.e the cached data) on leaving the page - are there any other
> major considerations?


Session lives until the time specified for the session timeout


>
> Q4: Would the DataSource need to be serializable for it to be storeded
> as a session object?.


Not for in-proc sessions

 
Reply With Quote
 
mark4asp
Guest
Posts: n/a
 
      7th Jun 2007
On 7 Jun, 14:07, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
> On Jun 7, 2:08 pm, mark4asp <mark4...@gmail.com> wrote:
>
> > Q3: If I cache in the Session, apart from destroying the session
> > object (i.e the cached data) on leaving the page - are there any other
> > major considerations?

>
> Session lives until the time specified for the session timeout


Thanks Alexey, the individual Session objects can be removed with
Session.Remove("TheName"). Furthermore I can write a class to run on
every page which overrides OnInit() to check that these session
objects have been killed when the user is no longer on that
appropriate page.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session or Cache object Doogie Microsoft ASP .NET 0 12th Feb 2007 10:54 PM
Session Object v Data Cache Wee Bubba Microsoft ASP .NET 0 27th Jan 2005 02:54 PM
Saving DataTable to session vs saving a Custom object. John Kandell Microsoft C# .NET 4 13th Dec 2004 12:09 AM
Saving DataTable to session vs saving a Custom object. John Kandell Microsoft ASP .NET 4 10th Dec 2004 05:08 AM
How can i set the cache size for history object for one browser session. bassil Windows XP Internet Explorer 1 5th Nov 2003 03:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:24 PM.