Python Cache

Index Home MAE Python Interface > Python Index > Python Cache

Module Cache
Class Cache
Public Methods
__init__(self, objType, size)
__del__(self)
add(self, newKey, newOne)
removeKey(self, key)
remove(self, pos)
findPos(self, searchKey, fetchIfMissing)
exists(self, searchKey)
get(self, key)
__getitem__(self, pos)
__len__(self)

Module Cache

Class Cache

Public Methods

__init__(self, objType, size)

objType

the class of the object to cache

size: int

the maximum size allowable for the cache

Default value: 0


Constructor.

__del__(self)

Destructor

add(self, newKey, newOne)

newKey: int

newOne


Add a record to the cache. It must be valid().

Return int value:

removeKey(self, key)

key


Remove a record from the cache

Return bool value:

remove(self, pos)

pos: int


Remove a record from the cache

Return bool value:

findPos(self, searchKey, fetchIfMissing)

searchKey

fetchIfMissing: bool

Default value: True


Locate the cache position (-1 if not found)

Note: Pull into cache if fetchIfNotFound is True

Note: key must be a positive (non-zero) number

Return int value:

exists(self, searchKey)

searchKey: int


Check if key exists in list

Return bool value:

get(self, key)

key


Get pointer to data for the key. Check if result is valid().

Note: key must be a positive (non-zero) number

__getitem__(self, pos)

pos: int

position in cache, from 0+


This method allows the class instance to be indexed, e.g. HelloCache[2] to get the second element (not key==2)

Return value: the instance at position

__len__(self)

Return the size of the cache when using the len() function