developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks




using Delete to remove NotesDocument from cache
Don R Green 06/15/2007 11:02 AM
General 6.0.2 CF2 Windows 2000


I ran across a thread covering topics on how to modify an agent to run faster. One post discussed the use of Delete in a loop as listed below.

Dim session As New NotesSession
Dim coll As NotesDocumentCollection
Dim db As NotesDatabase
Dim docCur As NotesDocument, docNext As NotesDocument

Set db = session.CurrentDatabase
Set coll = db.UnprocessedDocuments
Set docCur = coll.GetFirstDocument

Do Until docCur Is Nothing
Call session.UpdateProcessedDoc(docCur)
Set docNext = coll.GetNextDocument(docCur)
' INSERT CODE HERE TO PROCESS A SINGLE DOCUMENT
Delete docCur ' so documents don't accumulate in cache
Set docCur = docNext
Loop

I’d like to know why the need for an additional NotesDocument: docNext? Wouldn’t docNext need to be deleted too? Would it not be the same if the agent was as the following?

Do Until docCur Is Nothing
Call session.UpdateProcessedDoc(docCur)
' INSERT CODE HERE TO PROCESS A SINGLE DOCUMENT
Delete docCur ' so documents don't accumulate in cache
Set docCur = coll.GetNextDocument(docCur)
Loop

Thanks!

Go back