Can scoped variables (variables stored in the applicationScope, sessionScope, requestScope etc.) be used to cache Notes document objects?
No. A document object is created using a session that is initialized when the request comes in, and closed when the request is done.
As a result, all the documents opened for the session are closed.
This is done for the following 2 reasons:
- A session is initialized for a thread, and cannot be used outside this thread. 2 requests for the same user can be processed by different threads, which doesn't work with sessions.
- It would keep to much memory in the server
Instead of trying to cache the document object in memory, read its data and cache the data.
Alternatively, keep the NoteID or UNID of the document and retrieve the document again later.