TSCache_Manager
What: class
Ancestor: TBase_Object
File: _CacheMa
Layer: 1
Platforms: C++, C#, Javascript, Pascal (Object), PHP, Python
A base abstract class for cache managers. The cache manager is used when multiple
different caches are used. It allows code that needs memory, which is not currently available, to
request that one or more caches release memory. Sometimes one cache will need other
caches to release memory, and the Free_Cache method allows that cache to be excluded
from the release that it is requesting. All handlers/caches known to the cache manager
have a priority associated with them. When memory is needed, the lowest priority
caches are emptied first (and only until the necessary contiguous memory has been
made available). Thus, the higher the priority value, the more likely data in that
cache will remain cached.
The class contains the following methods:
Add_Handler
void Add( PSCache Routine, int32 Priority )
procedure Add_Handler( Handler : TCache_Handler ; Delegation : TCache_Event ; Responder : PCache_Responder ; Cache : PSCache ; Priority : longint )
This routine adds a handler/responder to the handler list. Priority is the relative
priority of the cache associated with the handler. Various handlers are supported,
but only one is used if more than one is provided. When cache items need to be disposed
of, the one called - if more than one are defined - is chosen in this order:
Cache = Actual cache instance. Its Trim method is called to release data.
Responder = An instance of TCache_Responder.
Delegation = A delegation to a method of an object instance.
Handler = A callback function.
Delete
void Delete( PSCache Routine )
procedure Delete( Routine : PSCache )
This routine removes a cache from the cache handler list.
Free_Cache
void Free_Cache( int32 Siz, int32 Priority, PSCache Exclude )
procedure Free_Cache( Siz, Priority : longint ; Exclude : PSCache )
This routine calls the appropriate handler to free up Siz bytes of memory. A
specific handler can be excluded from this. Calling this with Exclude of nil, priority
of maxint, and Siz of -1, will zero all caches.
Initialize
void Initialize())
procedure Initialize
Initializes the instance.
Terminate
void Terminate()
procedure Terminate
Terminates the instance.