Can I cache a Java DAO in global.asa?

Results 1 to 2 of 2

Thread: Can I cache a Java DAO in global.asa?

  1. #1
    Jeff Ishaq Guest

    Default Can I cache a Java DAO in global.asa?

    Hey folks. I have a big table of about 9000 rows that my webapp uses all over the place. This data changes infrequently, so I&#039d like to cache it instead of running a query each time it&#039s needed. What is the best way to cache this? This seems to work:<BR><BR>Stash it in a 2D array in Global.asa&#039s Application_OnStart and just refer to the array in the webapp:<BR>Application("MyGlobalBigTable") = resultset.GetRows()<BR><BR>But, I would like to keep all of my data access in Java classes. Is there any harm (is it possible) to store a Java class, instead of a 2D array, in an application global? Here&#039s what I&#039m thinking in Application_OnStart:<BR>Sub Application_OnStart<BR>Dim TheDAO<BR>Set Application("TheDAO") = GetObject("java:myJavaDAO")<BR>Application("TheDAO ").fetchData<BR>&#039 Close the DB connection, retain the data<BR>Application("TheDAO").closeDBConnectionOnl y<BR>End Sub<BR><BR>Sub Application_OnEnd<BR>&#039 Destruct this object. <BR>If (!isNull( Application("TheDAO") ) Then<BR>Set Application("TheDAO") = Nothing<BR>End If<BR><BR>End Sub<BR><BR>Will this work, or is there a better way to go about doing what I need to do? Maybe invoking a singleton DAO object on server startup and just accessing it as necessary, instaed of making global.asa perform the allocation? <BR><BR>Thanks very much!<BR>-Jeff

  2. #2
    Join Date
    Dec 1969

    Default RE: Can I cache a Java DAO in global.asa?

    It&#039s difficult to say exactly without knowing the details of your object, BUT...<BR><BR>It&#039s not generally a good idea to store objects in Application or Session scope, because then all the ASP threads have to compete for access to this single object, which can cause serious marshalling and serialisation problems. If you wanted to do this using ADO might be tempted to say save the recordset as XML and then store the XML as a string in Application scope - simple datatypes like strings don&#039t have any serialisation problems. I&#039m not sure what the impact of parsing the XML is likely to be though...<BR><BR>You original 2D array solution is probably the best option.<BR><BR>Dunc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts