[Overview][Resource strings][Types][Classes][Index] Reference for unit 'CacheCls' (#fcl)

TCache

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Cache class

Declaration

Source position: cachecls.pp line 63

type TCache = class

protected

  FSlotCount: Integer;

  FSlots: PCacheSlotArray;

  FMRUSlot: PCacheSlot;

  FLRUSlot: PCacheSlot;

public

  constructor Create();

  

Create a new cache class.

  destructor Destroy; override;

  

Free the TCache class from memory

  function Add();

  

Add a data element to the list.

  function AddNew();

  

Add a new item to the list.

  function FindSlot();

  

Find data pointer in the list

  function IndexOf();

  

Return index of a data pointer in the list.

  procedure Remove();

  

Remove a data item from the list.

  property Data: Pointer; [rw]

  

Indexed access to data items

  property MRUSlot: PCacheSlot; [rw]

  

Most recent item slot.

  property LRUSlot: PCacheSlot; [r]

  

Last used item

  property SlotCount: Integer; [rw]

  

Number of slots in the list

  property Slots: PCacheSlot; [r]

  

Indexed array to the slots

  property OnIsDataEqual: TOnIsDataEqual; [rw]

  

Event to compare 2 items.

  property OnFreeSlot: TOnFreeSlot; [rw]

  

Event called when a slot is freed

end;

Inheritance

TCache

  

Cache class

|

TObject

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.

The latest version of this document can be found at lazarus-ccr.sourceforge.net.