This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
We created a windows explorer like gui using a servlet that generates the html to displays files and folders from a document management system. At first we thought the data would be relatively small (less than 100 files) but now it looks like it will be over 36,000 files and folders.
Currently, we create an index through an API from the DMS. We store this index in the session because of performance issues. Each file and folder is a class with attributes that is referenced by one class. The file and folder size aren't relevant since we only store attributes about them.
Finally my question.... having a session object with 36,000 classes referenced is a BAD idea right? Secondly, how could I determine the current size of the session?
"How big is the session" isn't actually a meaningful question. When you "store" something in the session you merely create a reference to it. So if you "add" a 36,000 item array to the session you have "used up" the size of one reference.
If you already have the objects in memory, storing references to them in the session only increases the memory footprint by the references. [ September 15, 2005: Message edited by: Bear Bibeault ]
Well, let's keep the caching-the-index-in-the-session question aside for a bit. Are you planning on generating an html with 36,000 files and folders to the client? If yes, then your performance would degrade because of the huge HTML that you will generate. If no, then you must be making the user search for certain files, right. Then wouldn't it be simpler and more efficient to query the data that is required by the user and not cache anything?
Ok, now going back to your caching the index:- You can cache your index in the Application scope. This has 2 advantages:- 1) reduced memory usage, because there is just one index and 2) any changes in the index would be reflected immediately across multiple sessions. You have to worry about synchronizing your index, but it's not much differrent than synchronizing your index thatis stored in the session.
However, the disadvantage with caching your index in application/session is that you will have challenge distributing your application across multiple servers. If you deploy your application on multiple web servers, and each web server caches it's own index, then you have to worry about synchronizing the indexes (indices?) across servers