Gets an item from the cache.
If an item is not in the cache, it is loaded using the loader the cache was initialized with.
The cache being used as a loading cache must have a load method defined which returns a pointer to the data relating to the key used. This method may, or may not, allocate memory or free memory previously allocated to data in the cache node.
Nodes fetched from the cache are protected from modification until all references to them are released. This means that the size of the cache must be carefully chosen to be no smaller than the maximum number of nodes which may be in use at any one time. Attempting to fetch a node when there are no free nodes to load the data into will result in a null being returned.
- Parameters
-
- cache - to get the entry from
|
- key - for the item to be returned
|
- exception - pointer to an exception data structure to be used if an exception occurs. See exceptions.h.
|
- Returns
- pointer to the requested item or null if too many items have been fetched and not released or the key is not valid