473,326 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to keep XSLs in Memory?

Hello,

I'm working on a project that uses over a hundred XLSs for transforming xml
documents. The project consists of several webservices (IIS) calling a few
dlls. This dlls make the business logic and are the ones that do the
transformation, so the XLSs are used by these dlls. Right now we have the
XSLs files on hard disk. This means there is lots of reading from disk. Since
reading from disk is much slower than reading from memory I am looking for a
way to keep them in memory.
Any Ideas?
Will IIS cache them? How? (Keep in mind they are used by the dlls)

I also was thinking simple work around. Using a RAM Disk, but it seems
Windows 2003 server does not support RAM Disks.

Any help?

Thanks.

Nov 12 '05 #1
15 2153
Alexis wrote:
I'm working on a project that uses over a hundred XLSs for transforming xml
documents. The project consists of several webservices (IIS) calling a few
dlls. This dlls make the business logic and are the ones that do the
transformation, so the XLSs are used by these dlls. Right now we have the
XSLs files on hard disk. This means there is lots of reading from disk. Since
reading from disk is much slower than reading from memory I am looking for a
way to keep them in memory.
Any Ideas?
Will IIS cache them? How? (Keep in mind they are used by the dlls)

I also was thinking simple work around. Using a RAM Disk, but it seems
Windows 2003 server does not support RAM Disks.


Just cache loaded XslTransform objects in cache instead of loading them
for each request. XslTransform.Transform() method is thread-safe, so
once XslTransaform object is created and Load() method has been called,
it's safe to run Transform() method in many threads.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #2
Thanks Oleg

Can you tell me how to cache the XslTransform?
Can you send me sample code of the first call that do the cache and the
other calls that will use the cache objets.?

Thanks again
Alexis

"Oleg Tkachenko [MVP]" wrote:
Alexis wrote:
I'm working on a project that uses over a hundred XLSs for transforming xml
documents. The project consists of several webservices (IIS) calling a few
dlls. This dlls make the business logic and are the ones that do the
transformation, so the XLSs are used by these dlls. Right now we have the
XSLs files on hard disk. This means there is lots of reading from disk. Since
reading from disk is much slower than reading from memory I am looking for a
way to keep them in memory.
Any Ideas?
Will IIS cache them? How? (Keep in mind they are used by the dlls)

I also was thinking simple work around. Using a RAM Disk, but it seems
Windows 2003 server does not support RAM Disks.


Just cache loaded XslTransform objects in cache instead of loading them
for each request. XslTransform.Transform() method is thread-safe, so
once XslTransaform object is created and Load() method has been called,
it's safe to run Transform() method in many threads.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #3
Alexis wrote:
Can you tell me how to cache the XslTransform?
Can you send me sample code of the first call that do the cache and the
other calls that will use the cache objets.?


If you are talking about ASP.NET, you can use standard caching methods.
Take a look at
http://msdn.microsoft.com/library/de...netchapt09.asp
for a sample.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #4
Thanks again.
I read the article but they are using the Application object to store the
cached objects. But as I said in the first question the transformation is
done by a Dll so I don't have access to the Application Object there.

Do you know of a method of caching without using the Application object?

More specific caching from a Dll.

You can read again the first question to understand better the problem I am
having.

Thanks again.

"Oleg Tkachenko [MVP]" wrote:
Alexis wrote:
Can you tell me how to cache the XslTransform?
Can you send me sample code of the first call that do the cache and the
other calls that will use the cache objets.?


If you are talking about ASP.NET, you can use standard caching methods.
Take a look at
http://msdn.microsoft.com/library/de...netchapt09.asp
for a sample.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #5
On Mon, 21 Mar 2005 06:59:04 -0800, Alexis wrote:
I also was thinking simple work around. Using a RAM Disk, but it seems
Windows 2003 server does not support RAM Disks.


There's no RAM disk driver *shipped* with Windows 2000 and above, but there
are many third-party RAM disk drivers available that will work. Seek (on
Google) and ye shall find.
Nov 12 '05 #6
On Tue, 22 Mar 2005 09:37:04 -0800, Alexis wrote:
But as I said in the first question the transformation is
done by a Dll so I don't have access to the Application Object there.


Your original post said the DLL will be called by a web service. So there
ultimately is an Application object available, which your DLL can access
with this:

HttpContext.Current.ApplicationInstance

Or, if you don't mind if your XSL objects are occasionally flushed from the
cache and will be reloaded, you can make more direct use of the ASP.NET
Cache this way:

HttpContext.Current.Cache
Nov 12 '05 #7
Alexis wrote:
I read the article but they are using the Application object to store the
cached objects. But as I said in the first question the transformation is
done by a Dll so I don't have access to the Application Object there.

Do you know of a method of caching without using the Application object?


Quick and dirty cache is just plain Hashtable. You can make it better
using WeakReferences.
Otherwise take a look at the "Caching Application Block"
http://msdn.microsoft.com/library/de...l/caching1.asp

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #8
Oleg Thanks again I really appreciate your help
But you are getting me to nowhere. Graet book index but little contect.
Thanks anyway for trying.

"Oleg Tkachenko [MVP]" wrote:
Alexis wrote:
I read the article but they are using the Application object to store the
cached objects. But as I said in the first question the transformation is
done by a Dll so I don't have access to the Application Object there.

Do you know of a method of caching without using the Application object?


Quick and dirty cache is just plain Hashtable. You can make it better
using WeakReferences.
Otherwise take a look at the "Caching Application Block"
http://msdn.microsoft.com/library/de...l/caching1.asp

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #9
Ross Thankyou very much.

I have not have time to try it yet but it make a lot of sense. I was just
wondering how efficient it may be. The whole purpose of keeping the XSL files
or objects in memory is to improve performance. Do you know if accessing the
HttpContext from a dll will have some impact on performance?

Thanks a lot again I really appreciate your help.
"Ross Presser" wrote:
On Tue, 22 Mar 2005 09:37:04 -0800, Alexis wrote:
But as I said in the first question the transformation is
done by a Dll so I don't have access to the Application Object there.


Your original post said the DLL will be called by a web service. So there
ultimately is an Application object available, which your DLL can access
with this:

HttpContext.Current.ApplicationInstance

Or, if you don't mind if your XSL objects are occasionally flushed from the
cache and will be reloaded, you can make more direct use of the ASP.NET
Cache this way:

HttpContext.Current.Cache

Nov 12 '05 #10
I am not really a fan of using third-party software but thanks any way for
the tip.

"Ross Presser" wrote:
On Mon, 21 Mar 2005 06:59:04 -0800, Alexis wrote:
I also was thinking simple work around. Using a RAM Disk, but it seems
Windows 2003 server does not support RAM Disks.


There's no RAM disk driver *shipped* with Windows 2000 and above, but there
are many third-party RAM disk drivers available that will work. Seek (on
Google) and ye shall find.

Nov 12 '05 #11
On Thu, 24 Mar 2005 07:07:03 -0800, Alexis wrote:
I have not have time to try it yet but it make a lot of sense. I was just
wondering how efficient it may be. The whole purpose of keeping the XSL files
or objects in memory is to improve performance. Do you know if accessing the
HttpContext from a dll will have some impact on performance?


Well, the thing of it is, where do you expect the DLL to cache it? You need
something that has persistence between invocations of your DLL, and the
easiest answer to that is to let ASP.NET handle it. And the way to access
ASP.NET's cache is through HttpContext.Current.

I could be wrong about this, and you might want to check the other dotnet
newsgroups for a more informed opinion.
Nov 12 '05 #12
What I want to keep in memory are XSLs files used for transformation not the
data so the contenct don't change, but I don't think ASP.NET will cache XSL
files. See my original goal is to keep XSL files in memory instead of having
to read them from disk on every request

"Ross Presser" wrote:
On Thu, 24 Mar 2005 07:07:03 -0800, Alexis wrote:
I have not have time to try it yet but it make a lot of sense. I was just
wondering how efficient it may be. The whole purpose of keeping the XSL files
or objects in memory is to improve performance. Do you know if accessing the
HttpContext from a dll will have some impact on performance?


Well, the thing of it is, where do you expect the DLL to cache it? You need
something that has persistence between invocations of your DLL, and the
easiest answer to that is to let ASP.NET handle it. And the way to access
ASP.NET's cache is through HttpContext.Current.

I could be wrong about this, and you might want to check the other dotnet
newsgroups for a more informed opinion.

Nov 12 '05 #13
On Fri, 25 Mar 2005 07:27:03 -0800, Alexis wrote:
What I want to keep in memory are XSLs files used for transformation not the
data so the contenct don't change, but I don't think ASP.NET will cache XSL
files. See my original goal is to keep XSL files in memory instead of having
to read them from disk on every request


ASP.NET's Application object, or Cache object, will cache ANY object, with
whatever expiration/retention rules you care to set up.
Nov 12 '05 #14
I would like to try to cache the xsl objects them.
Can you provide me with a code sample? I have not used cahing in yet.

"Ross Presser" wrote:
On Fri, 25 Mar 2005 07:27:03 -0800, Alexis wrote:
What I want to keep in memory are XSLs files used for transformation not the
data so the contenct don't change, but I don't think ASP.NET will cache XSL
files. See my original goal is to keep XSL files in memory instead of having
to read them from disk on every request


ASP.NET's Application object, or Cache object, will cache ANY object, with
whatever expiration/retention rules you care to set up.

Nov 12 '05 #15
On Wed, 30 Mar 2005 07:05:07 -0800, Alexis wrote:
I would like to try to cache the xsl objects them.
Can you provide me with a code sample? I have not used cahing in yet.


Hope you don't mind VB.NET ...

' this function will look in the ASP.NET cache for an XSLTransform;
' if it's there, it will return it;
' if it's not, it will call CreateTheXSLT() to create it.
Public Function GetXSLTObject(ByVal key As String) _
As System.Xml.Xsl.XslTransform
' get a handle to the ASP.NET cache
Dim c As Web.Caching.Cache
c = HttpContext.Current.Cache

Dim x As System.Xml.Xsl.XslTransform
If c.Item(key) Is Nothing Then
' it wasn't in the cache ...
' create it fresh, then put it in the cache
x = CreateTheXSLT(key)
' sliding expiration of 2 hrs ...
' if we don't use it for 2 hrs, ASP.NET is allowed to
' purge it from the cache
c.Add(key, x, Nothing, Nothing, _
System.TimeSpan.FromHours(2), _
Caching.CacheItemPriority.Normal, _
Nothing)
Return x
Else
' yaay, it was in the cache ... return it
x = c.Item(key)
Return x
End If

End Function
Nov 12 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Zillian | last post by:
Dear XML chiefs, I have two questions: * How many XSLs do you use for your websites? Is it better to split big Stylesheets in smaller ones (does it speed up the transformation to html?) What...
7
by: Clement | last post by:
hi, i have an asp.net site and is using SQL Server 2k. i realize the aspnet_wp.exe memory usage keep growing and i will receive an error for the pages that call the sql connection. others page...
0
by: Alexis | last post by:
Hello, I'm working on a project that uses over a hundred XLSs for transforming xml documents. The project consists of several webservices (IIS) calling a few dlls. This dlls make the business...
3
by: patrickbeaudoin | last post by:
Hi, I have some application that use the same library in the gac. All these application use the same xml document. I would like to keep that xml document loaded in memoy and dont have to reload...
11
by: cty0000 | last post by:
I have some quiestion... I want to draw line,point,rectangles and etc... on the from So I code like this.. public update() { g = this.CreateGraphics(); g.FillRectangle(Brushes.White, x1,...
7
by: mail747097 | last post by:
I would like to keep IIS alive on my web site and prevent Application_End from occuring in global.asax. Any ideas?
4
by: Daniel | last post by:
is there some per-process-limit on memory in .net processes? is there any way to increase it? i keep getting System.OutOfMemoryException when my box has 8 gigs of unused memory.
1
by: =?Utf-8?B?QWxwaGFwYWdl?= | last post by:
Hello, I have built an object which does some jobs on a particular server. There can have lots of this object running concurrently. I want to know what is the best way to optimize my...
6
by: Guillermo | last post by:
Hi, I need a script to keep running in the background after it's loaded some data. It will make this data available to the main program in the form of a dictionary, but I don't want to reload...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.