xml file read write question

  • Thread starter David Arden Stevensonn
  • Start date
D

David Arden Stevensonn

Say I have an XML file on my website that gets read alot (by a c# aspx page)
but written to occasionally (also by the same c# aspx page) . Its a simple
caching situation based on time. Example: If x minutes have elapsed return
the XML from the file and then rewrite the XML file for the next user and
reset the clock. If x minutes havent elapsed just return the XML from the
file.

Do I need to be concerned for any concurrent read/writes or other
concurrency issues? Say userA comes to the page gets a read, while a
nanosecond later userB goes to the page and triggers a read/write, or
vice-versa. Can I get a deadlock/error? If so what strategy can I use to
avoid it?

Thanks in advance
David
 
P

Peter Rilling

Is this a large file that you need to process? Is a single file going to be
used by all your users, or will each user have a separate file?

If they all share the same file, and the file is not too large, then you
might consider putting it in something like an application level variable
(that is the DOM), then make changes to the copy in memory and write it back
to disk. That way the memory copy is always the gold copy and the disk
version is only a backup that could be loaded if the application has to
restart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top