user596342
user596342

Reputation: 21

should I cache a 600KB xml file in memory? or is it sufficient by just using XMLTextReader?

I am not sure if I should cache an xml file that my application will be using. I don't know how frequently it will be reading from the xml file. Please advice. Thank You.

Upvotes: 1

Views: 129

Answers (2)

Dustin Davis
Dustin Davis

Reputation: 14585

Depends. If memory isn't a concern but performance is, then read in the structure using XmlReader and store it. This way it won't need to be parsed again. If it's not going to be reader frequently then don't bother. Xml parsing isn't cheap. 600KB won't break the bank on memory but you'll have to deal with caching setup, but it will be worth the performance benefits especailly if you do any transforms on it or schema validation.

if this is website then store it as a static

public static XmlReader ...

That way it's shared across all sessions.

Upvotes: 2

Gregory A Beamer
Gregory A Beamer

Reputation: 17010

This is an "it depends" answer.

  1. Do you benefit from caching? Enough of a speed difference? Add enough scalability? etc.
  2. Does the file change very often? This is more of a "how long to cache question.
  3. Do people need instant access to changes?

I don't think you gain much with a 600kb XML file with caching. It is rather small. Unless ... you hit the same data over and over again, in which case not caching may affect scalability.

The short answer: I don't know enough about your application to give you a single answer.

Upvotes: 1

Related Questions