Cachewalk

Retrieving cache entries 



The following sample shows how to enumerate the cache. The function RetrieveEntries finds all entries in the cachegroup and the OnEntry event  is called for each entry found. When you use RetrieveEntries you must add the GroupID for the cachegroup you want search. In most cases you can use 0, which means all cachegroups. 

From OnEntry you can get the information about the entry from IECache.Entryinfo record:

TEntryInfo = record
  SourceUrlName: string;
  LocalFileName: string;
  EntryType: DWORD;
  UseCount: DWORD;
  HitRate: DWORD;
  FSize: DWORD;
  LastModifiedTime: TDateTime;
  ExpireTime: TDateTime;
  LastAccessTime: TDateTime;
  LastSyncTime: TDateTime;
  HeaderInfo: string;
  FileExtension: string;
  ExemptDelta: DWORD;
end;

The following sample shows how these functions are used to add all cached urls to a listbox:

 

procedure TForm1.Button1Click(Sender: TObject);
begin
  Iecache1.RetrieveEntries(0);
end;

procedure TForm1.IECache1Entry(Sender: TObject; var Cancel: Boolean);
begin
  ListBox1.Items.Add(IECache1.EntryInfo.SourceUrlName);
end;

 

You can cancel the retrieving of entries in OnEntry: Set value of Cancel:=TRUE.

 

In some situations it might be preferable to use FindFirstEntry, FindNextEntry and CloseFindEntry. The result is the same:

 

procedure TForm1.Button1Click(Sender: TObject);
begin
 if IECache1.FindFirstEntry(0) = S_OK
 then begin
   Listbox1.Items.Add(IECache1.EntryInfo.SourceUrlName);
   while IECache1.FindNextEntry = S_OK do
   Listbox1.Items.Add(IECache1.EntryInfo.SourceUrlName);
 end;
IECache1.CloseFindEntry;
end;

If you use FindFirstEntry and FindNextEntry you  are responsable for the final call to CloseFindEntry.