The built-in collection of Application objects has Contents designed for storing simple types, and the default Application ("key") can be used.
However, Application.Contents cannot store objects, and can store vbs arrays, but in JavaScript, even arrays cannot be placed.
When using Application.Contents, you can only use ugly ones such as:
for(vari=0;i<15000;i++){
Application.Lock();
//Application.Contents(i)="sdfdsffdsaf";
Application(i)="sdfdsffdsaf";
Application.Unlock();}
Here I store 1.5w Strings in Application.Contents, which took a total of 234ms.
After using Application.StaticObjects instead:
Define a Dictionary as a StaticObject to store data, because StaticObject does not allow direct access.
<objectid="dict"runat="server"scope="Application"progid="Scripting.Dictionary"></object>
Scripting.Dictionary itself is very fast and will not have much impact on comparing StaticObjects collection speed.
Dictionary's speed:
vard=newActiveXObject("Scripting.Dictionary");
for(vari=0;i<15000;i++){
d.Item(i)="sdfdsffdsaf";}
1.5w interpolation, 172ms
Of course, the custom object vard=newObject();d[i]=.. is faster, 1.5w times only takes 80-90ms, but the function is much weaker, so you still use a dictionary.
See the official test below
for(vari=0;i<15000;i++){
Application.Lock();
Application.StaticObjects("dict").Item(i)="sdfdsffdsaf";
Application.Unlock();}
The time is as long as 6953ms. It is initially judged that the access speed of the StaticObjects collection cannot meet the requirements of Cache. This speed is almost the same as the time when ADOOLEDB reads sqlserver2000.
However, I don't plan to give up immediately, because the advantage of StaticObjects is that it can store Objects, and Dictionary can also store other objects, which can be used as cache objects, not just data.
I put an Object in Application.StaticObjects("dict"):
Application.StaticObjects("dict").Item("o")=newObject();
for(vari=0;i<15000;i++){
Application.Lock();
Application.StaticObjects("dict").Item("o")[i]="sdfdsffdsaf";
Application.Unlock();}
6656ms, a little faster. One more layer of Object does not slow down the speed. The slow speed is not because of the complex structure, but because of the access occupation of StaticObjects.
Pre-store dict's reference
vart=Application.StaticObjects("dict");
for(vari=0;i<15000;i++){
Application.Lock();