D
David Gagné
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.
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.