By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,057 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,057 IT Pros & Developers. It's quick & easy.

Caching Help Needed

P: n/a
Hi,
I have problem related to Caching of data. I am reading large xml
file and putting this xml in dataset, since this dataset will contain
many datatable's inside. And each datatable might be big in data. Each
user will contain its seperate xml file, so when I create xml file for
each user, I am putting this xml DataSet in Cache object, but when I
try to populate my controls using Cache object, I am faching weired
problem. As some times it populates the controls and some times it
doesnt, although the xml files have been created for that user.
Along with this I am using same cache object name for every user.

So please tell me what could be the reason for cache is not able to
populate the controls on some time.???and what could be best usage for
concurrent users??Sessions or Cache??

Thanks in Advance.
Manoj Singh

Sep 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Manoj,

The cache has a scope of an application, so if you have a key such as
"xmlFile" for the cache, then you will be reading/writing to it for all of
the users, which I don't think is what you want.

Rather, you should attach a unique identifier for the user to the end of
the "xmlFile" to make sure that each user has their own version of the
cache, like so:

// Make the key.
private const string XmlFileKeyFormat = "xmlFile_{0}";

private static string GetXmlFileKey(string userId)
{
// Perform error checking against user id here.

// Format the string.
return string.Format(XmlFileKeyFormat, userId);
}

public static XmlDocument GetXmlFile(string userId)
{
// Return the xml file.
return (XmlDocument) HttpContext.Current.Cache[GetXmlFileKey(userId)];
}

public static void SetXmlFile(string userId, XmlDocument document)
{
// Set the document.
HttpContext.Current.Cache[GetXmlFileKey(userId)] = document;
}

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Aryan" <ma*********@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Hi,
I have problem related to Caching of data. I am reading large xml
file and putting this xml in dataset, since this dataset will contain
many datatable's inside. And each datatable might be big in data. Each
user will contain its seperate xml file, so when I create xml file for
each user, I am putting this xml DataSet in Cache object, but when I
try to populate my controls using Cache object, I am faching weired
problem. As some times it populates the controls and some times it
doesnt, although the xml files have been created for that user.
Along with this I am using same cache object name for every user.

So please tell me what could be the reason for cache is not able to
populate the controls on some time.???and what could be best usage for
concurrent users??Sessions or Cache??

Thanks in Advance.
Manoj Singh

Sep 21 '06 #2

P: n/a

Per User = Session
Everybody = Cache

That's the simple formula.

You could uniquely name files/keys for the Cache, but that feels weird. But
I guess its how long you want to Cache it.
You might want to check out
http://sholliday.spaces.live.com/ 10/24/2005 entry


"Aryan" <ma*********@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Hi,
I have problem related to Caching of data. I am reading large xml
file and putting this xml in dataset, since this dataset will contain
many datatable's inside. And each datatable might be big in data. Each
user will contain its seperate xml file, so when I create xml file for
each user, I am putting this xml DataSet in Cache object, but when I
try to populate my controls using Cache object, I am faching weired
problem. As some times it populates the controls and some times it
doesnt, although the xml files have been created for that user.
Along with this I am using same cache object name for every user.

So please tell me what could be the reason for cache is not able to
populate the controls on some time.???and what could be best usage for
concurrent users??Sessions or Cache??

Thanks in Advance.
Manoj Singh

Sep 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.