开发者

Edit used file without resetting IIS

开发者 https://www.devze.com 2023-02-07 11:46 出处:网络
Environement : .net 2.0, windows server 2005. I have a problem : I have a website that has a lot of traffic, so one of my XML file is always opened by a document(...) function (inside a xslt template

Environement : .net 2.0, windows server 2005.

I have a problem : I have a website that has a lot of traffic, so one of my XML file is always opened by a document(...) function (inside a xslt template).

S开发者_JS百科o : how can I update this xml file without resetting the server? Or maybe , how can I apply a cache strategy to the document(...) function so it won't load the file every time it needs to and it'll update the cache when I change the file.

Thanks

Rémi


The easiest way would be to have the application load the contents of the file into memory and then release the file lock.

Stage 2 would be to make your edits via the same application, so it can save the file, destroy the cached object and use the latest version.

You could just implement Stage 1, and have the in-memory version expire at set intervals, which would reduce contention on the file - but there would be a chance that it attempts to read the file while it is locked by your external editing process and vice versa - just a much smaller chance than if you keep hold of the file. You could improve this by attempting to read the FileInfo to see if it has changed since you loaded it - any problems reading the FileInfo should result in not destroying the in-memory version.

0

精彩评论

暂无评论...
验证码 换一张
取 消