469,929 Members | 1,742 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

Caching data

Hi,
I'm using ASP on Windows 2K. I'm NOT using ASP.Net. I have static data in an
XML file that I would like to cache. Based on my idea explained below, is it
an approach that should scale correctly? Considering that the cache will be
used extensively, will this create a bottleneck?

My idea is:
In the application_OnStart(), I load the xml file and store the xml string
in an application variable:
sub application_OnStart()
...
myXmlDOM.Load("myfile.xml")
Application("myXMLString") = myXmlDOM.xml
' Would have been insteresting to store the parsed xml in the
application
' but it returns an error saying the object can't be stored in
application variable
' because it has appartment threaded behaviors.
' Set Application("myXML") = myXmlDOM doesn't work
...
end sub

Then I create an asp file (cache.asp) that has functions to get information
from this xml string.
function getName(theID)
...

set oDs = Server.CreateObject("MSXML2.DOMDocument")
...
if oDs.loadXML(Application("myXMLString")) then
...
xpath = ... theID
' Get the value using selectSingleNode(xpath)
...
end if
set oDs = nothing
end function

function getID(theName)
...

set oDs = Server.CreateObject("MSXML2.DOMDocument")
...
if oDs.loadXML(Application("myXMLString")) then
...
xpath = ... theName
' Get the value using selectSingleNode(xpath)
...
end if
set oDs = nothing
end function

Thanks for you advise,
David.
Jul 19 '05 #1
5 2676
There is a thread-safe version of the XMLDom object
(Msxml2.FreeThreadedDOMDocument) that you could store in the Application
object. I am not familiar with the performance or concurrency issues
associated with it.
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"David Gagné" <ga*********@sympatico.ca> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
Hi,
I'm using ASP on Windows 2K. I'm NOT using ASP.Net. I have static data in an XML file that I would like to cache. Based on my idea explained below, is it an approach that should scale correctly? Considering that the cache will be used extensively, will this create a bottleneck?

My idea is:
In the application_OnStart(), I load the xml file and store the xml string
in an application variable:
sub application_OnStart()
...
myXmlDOM.Load("myfile.xml")
Application("myXMLString") = myXmlDOM.xml
' Would have been insteresting to store the parsed xml in the
application
' but it returns an error saying the object can't be stored in
application variable
' because it has appartment threaded behaviors.
' Set Application("myXML") = myXmlDOM doesn't work
...
end sub

Then I create an asp file (cache.asp) that has functions to get information from this xml string.
function getName(theID)
...

set oDs = Server.CreateObject("MSXML2.DOMDocument")
...
if oDs.loadXML(Application("myXMLString")) then
...
xpath = ... theID
' Get the value using selectSingleNode(xpath)
...
end if
set oDs = nothing
end function

function getID(theName)
...

set oDs = Server.CreateObject("MSXML2.DOMDocument")
...
if oDs.loadXML(Application("myXMLString")) then
...
xpath = ... theName
' Get the value using selectSingleNode(xpath)
...
end if
set oDs = nothing
end function

Thanks for you advise,
David.

Jul 19 '05 #2

"David Gagné" <ga*********@sympatico.ca> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
Hi,
I'm using ASP on Windows 2K. I'm NOT using ASP.Net. I have static data in an XML file that I would like to cache. Based on my idea explained below, is it an approach that should scale correctly? Considering that the cache will be used extensively, will this create a bottleneck?

My idea is:
In the application_OnStart(), I load the xml file and store the xml string in an application variable:
sub application_OnStart()
...
myXmlDOM.Load("myfile.xml")
Application("myXMLString") = myXmlDOM.xml
' Would have been insteresting to store the parsed xml in the
application
' but it returns an error saying the object can't be stored in
application variable
' because it has appartment threaded behaviors.
' Set Application("myXML") = myXmlDOM doesn't work
...
end sub

Then I create an asp file (cache.asp) that has functions to get information from this xml string.
function getName(theID)
...

set oDs = Server.CreateObject("MSXML2.DOMDocument")
...
if oDs.loadXML(Application("myXMLString")) then
...
xpath = ... theID
' Get the value using selectSingleNode(xpath)
...
end if
set oDs = nothing
end function

function getID(theName)
...

set oDs = Server.CreateObject("MSXML2.DOMDocument")
...
if oDs.loadXML(Application("myXMLString")) then
...
xpath = ... theName
' Get the value using selectSingleNode(xpath)
...
end if
set oDs = nothing
end function

Thanks for you advise,
David.


Use the thread safe version to save the parsed document to an
Application variable:

MSXML2.FreeThreadedDOMDocument.4.0

As for bottlenecks, I imagine that you will actually see quite an
improvement in performance by using a cached document. Let me know how
it turns out.

Notes:
1. In the future, please indicate what version of MSXML you are using.
2. Consider using version specific ProgID's, as version independent
ProgID's have been deprecated
3. Consider using "NewParser":

DOM.setProperty("NewParser",True)

HTH
-Chris Hohmann
Jul 19 '05 #3
David,

I have done the same in the past.
I have found the dom object to be a little sluggish
How large is the xml?.

-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #4
Not very big, let say 10K.
How big when you started having problems?
Where you using MSXML 4.0, the free threaded version and the "NewParser" ?

What do you mean "sluggish"?

Thanks,
David.

"dlbjr" <do******@do.u> wrote in message
news:RWWsb.189$Qy4.14466@typhoon01...
David,

I have done the same in the past.
I have found the dom object to be a little sluggish
How large is the xml?.

-dlbjr

Discerning resolutions for the alms

Jul 19 '05 #5
Yes I use 4
I found under heavy traffic the Dom parsing seem to lag client response.

This may give you an idea.

I store ID and Value data in an Application Level array.
I build a dynamic drop down from the array and set the selected item per
client request.

Much faster than using any XML as Application string.

HTH
-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by kevin | last post: by
reply views Thread by Martin | last post: by
10 posts views Thread by Jon Maz | last post: by
10 posts views Thread by BillGatesFan | last post: by
reply views Thread by Rick Hein | last post: by
4 posts views Thread by DylanM | last post: by
2 posts views Thread by George1776 | last post: by
3 posts views Thread by Gary W. Smith | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.