views:

272

answers:

4

I'm currently rewriting some PHP 4 code to Classic ASP (don't ask) and trying to work out if there's a better way to load a large Map into memory than just hard coding each pair in.

To give you an idea, there's around 300 unique key value pairs in the hashed array definition (or whatever it's called) in the PHP.
I'm tempted to just do that again in ASP like:

<%
dim map
set map = CreateObject("Scripting.Dictionary")
map.add('key','value')
map.add('key2','value2')
...
%>

With this map getting loaded into memory for each call, is there any other way of doing this that would be quicker? The only time the map is used is to find out if an argument matches up to one of the keys - if so the value is pulled out and returned.

Thanks for your help.

A: 

If you are using classic ASP then you will have to depend on one of these objects. Using a database table or XML are other options you can explore.

I would suggest you to make sure to not call this again and again if you are using this for about 300 items.

schar
Unfortunately this code will be called around 500,000 times per day so needs to be efficient (quite hard with such a big hash map).
James Camfield
A: 

I've just found out about a global ASP cache which would allow me to build the map once, put it in the cache and any future request can simply pull it out of the cache. The cache is held in-memory so performance should be dramatically increased.

<%
Application.Contents(object here)
%>

Cheers

James Camfield
A: 

Well you need to understand the Application and the Session objects in ASP before continuing with the project. I was under the assumption that you have a reason to keep that outside the global cache (like constantly having to update the contents of the object based on the user preference)

All the best

schar
A: 

Like schar says, store the dictionary object in the Application object.

Michael Pryor