Caching Help Needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aryan

    Caching Help Needed

    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

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Caching Help Needed

    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 XmlFileKeyForma t = "xmlFile_{0 }";

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

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

    public static XmlDocument GetXmlFile(stri ng userId)
    {
    // Return the xml file.
    return (XmlDocument) HttpContext.Cur rent.Cache[GetXmlFileKey(u serId)];
    }

    public static void SetXmlFile(stri ng userId, XmlDocument document)
    {
    // Set the document.
    HttpContext.Cur rent.Cache[GetXmlFileKey(u serId)] = document;
    }

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m



    "Aryan" <manoj241176@gm ail.comwrote in message
    news:1158860421 .964334.12570@k 70g2000cwa.goog legroups.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
    >

    Comment

    • sloan

      #3
      Re: Caching Help Needed


      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" <manoj241176@gm ail.comwrote in message
      news:1158860421 .964334.12570@k 70g2000cwa.goog legroups.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
      >

      Comment

      Working...