Classic ASP application-wide initializations and object caching
- by slack3r
In classic ASP (which I am forced to use), I have a few factory functions, that is, functions
that return classes. I use JScript.
In one include file I use these factory functions to create some classes that are used throughout the application. This include file is included with the #include directive in all pages.
These factory functions do some "heavy lifting" and I don't want them to be executed on every page load.
So, to make this clear I have something like this:
// factory.inc
function make_class(arg1, arg2) {
function klass() {
//...
}
// ... Some heavy stuff
return klass;
}
// init.inc, included everywhere
<!-- #include FILE="factory.inc" -->
// ...
MyClass1 = make_class(myarg01, myarg02);
MyClass2 = make_class(myarg11, myarg12);
//...
How can I achieve the same effect without calling make_class on every page load?
I know that
I can't cache the classes in the Application object
I can't use the Application_OnStart hook in Global.asa
I could probably create a scripting component, but I really don't want to do that
So, is there something else I can do? Maybe some way to achieve caching of these classes, which are really objects in JScript.
PS: [further clarification] In the above code "heavy stuff" is not so heavy, but I just want to know if there's a way to avoid it being executed all the time. It reads database meta information, builds a table of the primary keys in the database and another table that resolves strings to classes, etc.