The Conroy & Conroy Subroutine Library (2021.3 edition)

TCache
What: class
File: _Cache
Ancestor: TBase_Delphi_Object
Layer: 1
Platforms: C++, C#, Javascript, Pascal (Object), PHP, Python

Defines a base abstract class for caching. It contains the following methods:

Clear
void Clear()
procedure Clear
Clears cache.

Initialize
void Initialize()
procedure Initialize
Initialize object.

Read_Cache
int32 Read_Cache( void* Data, int32 Address, int32 Size )
function Read_Cache( var Data ; Address, Size : longint ) : longint
Reads up to Size bytes from the cache for the specified address. Returns the number of bytes actually read (if 0 then the data was not cached). Cached data is copied to Data.

Set_Max_Size
void Set_Max_Size( int32 Size )
procedure Set_Max_Size( Size : longint )
Sets maximum cache size in bytes. If this is more than is currently cached, some cache is thrown away.

Terminate
void Terminate()
procedure Terminate
Terminate object.

Trim
void Trim()
procedure Trim
Discards the oldest cache item.

Write_Cache
void Write_Cache( const void* Data, int32 Address, int32 Size )
procedure Write_Cache( const Data ; Address, Size : longint )
Writes to cache up to Size bytes from Data.

Get_Max_Size
int32 Get_Max_Size()
function Get_Max_Size : longint
Gets current maximum cache size in bytes.

Get_Size
int32 Get_Size()
function Get_Size : longint
Returns amount of currently cached data, in bytes.

Get_Stats
int32 Get_Stats( int32 Index, int32 &Address )
function Get_Stats( Index : longint ; var Address : longint ) : longint

Lock
bool Lock( int32 Address )
function Lock( Address : longint ) : boolean
Locks the data starting at the specified address into memory so that it is not thrown away. Returns false if the specified data is not in the cache.

Unlock
bool Unlock( int32 Address )
function Unlock( Address : longint ) : boolean
Unlocks the data starting at the specified address in memory. Returns false if the specified data is not in the cache, or if it is not locked.

Get_Hits
int32 Get_Hits()
function Get_Hits : longint
Returns the total cache read hits.

Get_Misses
int32 Get_Misses()
function Get_Misses : longint
Returns the total cache read misses.

Get_Writes
int32 Get_Writes()
function Get_Writes : longint
Returns the total cache writes.

Get_Turns
int32 Get_Turns()
function Get_Turns : longint
Returns the number of times that a cached item had to be discarded to make room for a new item.

Get_Replacements
int32 Get_Replacements()
function Get_Replacements : longint
Returns the number of writes when the item was already in the cache.

Set_Hits
void Set_Hits( int32 Value )
procedure Set_Hits( Value : longint )
Sets the total cache read hits.

Set_Misses
void Set_Misses( int32 Value )
procedure Set_Misses( Value : longint )
Sets the total cache read misses.

Set_Writes
void Set_Writes( int32 Value ))
procedure Set_Writes( Value : longint )
Sets the total cache writes.

Set_Turns
void Set_Turns( int32 Value )
procedure Set_Turns( Value : longint )
Sets the number of times that a cached item had to be discarded to make room for a new item.

Set_Replacements
void Set_Replacements( int32 Value )
procedure Set_Replacements( Value : longint )
Sets the number of writes when the item was already in the cache.

Hits
int32 Hits() { return Get_Hits(); }
property Hits : longint read Get_Hits write Set_Hits
Sets the total cache read hits.

Misses
int32 Misses() { return Get_Misses(); })
property Misses : longint read Get_Misses write Set_Misses
Sets the total cache read misses.

Writes
int32 Writes() { return Get_Writes(); }
property Writes : longint read Get_Writes write Set_Writes
Sets the total cache writes.

Turns
int32 Turns() { return Get_Turns(); }
property Turns : longint read Get_Turns write Set_Turns
Sets the number of times that a cached item had to be discarded to make room for a new item.

Replacements
int32 Replacements() { return Get_Replacements(); }
property Replacements : longint read Get_Replacements write Set_Replacements
Sets the number of writes when the item was already in the cache.