Sunday, 6 March 2011

Delete your Cache with LotusScript

I found this bit of code recently and it saves quite a lot of time by not having to close notes, find the data directory, delete cache.ndk and restart notes. Keep this in a button somewhere (perhaps a draft email) or place it on a database open event. It could also be used to help support users without being at their desk should a TopDesk call arrive at your desk.




Sub Click(Source As Button) Dim WorkSpace As New NotesUIWorkspace Dim DbCache As NotesDatabase Dim AllDocs As NotesDocumentCollection Dim Doc, nextDoc As NotesDocument Dim i As Integer On erreur Goto ErrorHandling Set DbCache = New NotesDatabase ("", "cache.ndk") Set AllDocs = DbCache.AllDocuments If AllDocs.Count > 0 Then Print "deleting documents from cache.ndk ..." Set Doc = AllDocs.GetFirstDocument While Not ( Doc Is Nothing ) i = i + 1 Set NextDoc = AllDocs.GetNextDocument ( Doc ) Print "deleting documents from cache (" & Cstr (i) & "/" & Cstr ( AllDocs.Count ) & ")" Call Doc.RemovePermanently ( True ) Set Doc = NextDoc Wend End If Print "Compacting cache.ndk" Call DbCache.Compact Exit Sub ErrorHandling : Resume Call WorkSpace.Prompt (1, "Cache.ndk Optimization", "An error has occured." ) End Sub


This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

No comments:

Post a Comment