Sign in Join
FPDoc Onlineexperiment

TCache class

In unit CacheCls

Cache class.

Declaration

pascal
TCache = class

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

DatapublicIndexed access to data items.
MRUSlotpublicMost recent item slot.
LRUSlotpublicLast used item.
SlotCountpublicNumber of slots in the list.
SlotspublicIndexed array to the slots.

Methods

CreatepublicCreate a new cache class.
DestroypublicFree the TCache class from memory.
AddpublicAdd a data element to the list.
AddNewpublicAdd a new item to the list.
FindSlotpublicFind data pointer in the list.
IndexOfpublicReturn index of a data pointer in the list.
RemovepublicRemove a data item from the list.

Events

OnIsDataEqualpublicEvent to compare 2 items.
OnFreeSlotpublicEvent called when a slot is freed.

Fields

FSlotCountprotected
FSlotsprotected
FMRUSlotprotected
FLRUSlotprotected

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.