Declaration¶
Source position: cachecls.pp line 69
type
TCache = class
public
constructor Create;
destructor Destroy;
function Add : Integer;
function AddNew : Integer;
function FindSlot : PCacheSlot;
function IndexOf : Integer;
procedure Remove;
property Data[SlotIndex : Integer]: Pointer; {rw}
property MRUSlot: PCacheSlot; {rw}
property LRUSlot: PCacheSlot; {r}
property SlotCount: Integer; {rw}
property Slots[SlotIndex : Integer]: PCacheSlot; {r}
property OnIsDataEqual: TOnIsDataEqual; {rw}
property OnFreeSlot: TOnFreeSlot; {rw}
end;
Description¶
TCache implements a cache class: it is a list-like class, but which uses a counting mechanism, and keeps a Most-Recent-Used list; this list represents the 'cache'. The list is internally kept as a doubly-linked list.
The Data property offers indexed access to the array of items. When accessing the array through this property, the MRUSlot property is updated.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| Data | public | Indexed access to data items. |
| LRUSlot read only | public | Last used item. |
| MRUSlot | public | Most recent item slot. |
| SlotCount | public | Number of slots in the list. |
| Slots read only | public | Indexed array to the slots. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| Add | public | Add a data element to the list. |
| AddNew | public | Add a new item to the list. |
| Create | public | Create a new cache class. |
| Destroy | public | Free the TCache class from memory. |
| FindSlot | public | Find data pointer in the list. |
| IndexOf | public | Return index of a data pointer in the list. |
| Remove | public | Remove a data item from the list. |
Events¶
| Member | Visibility | Description |
|---|---|---|
| OnFreeSlot | public | Event called when a slot is freed. |
| OnIsDataEqual | public | Event to compare 2 items. |