/*
JS cache class
Call method.
VaR OBJ = new cachehelper ();
OBJ. INIT ();
OBJ. addcache (1, "");
OBJ. addcache (2, "B ");
OBJ. addcache (3, "C ");
OBJ. addcache (4, "D ");
OBJ. addcache (5, "e ");
Alert (obj. getcachebykey (3 ))
*/
Function cachehelper ()
{
This. cache = new array ();
}
Cachehelper. Prototype = {
Init: function (){
This. cache = NULL;
This. cache = new array ();;
},
// Determine whether the cache exists
Isexist: function (ID)
{
For (VAR I = 0; I <this. cache. length; I ++)
{
If (this. cache [I]. ID = ID)
Return true;
}
Return false;
},
// Add Cache
Addcache: function (ID, value)
{
If (! This. isexist (ID ))
{
VaR OBJ = {ID: ID, value: Value };
This. cache. Push (OBJ );
}
},
// Obtain the cache size
Getcachesize: function ()
{
Return this. cache. length;
},
// Obtain the cache value based on the cache key value
Getcachebykey: function (ID)
{
For (VAR I = 0; I <this. cache. length; I ++)
{
If (this. cache [I]. ID = ID)
Return this. cache [I]. value;
}
Return "";
}
}