The look-aside cache service stores the results of computations for later use. Each cache entry is uniquely identified by a string function name, an integer key (which the executive uses to store multiple outputs for a single module), the number of input parameters, and the set of input parameter values.
The input parameters and the Object to be cached must be Data Explorer Objects.
Associating data with a cache entry. User data not already in the form of an Object can be associated with a cache entry by means of a Private Object (see 12.5 , "Private Class"), encapsulating the data in an object. To associate more than one Object with a cache entry, use a Group to contain the Objects.
Losing a cache entry. Cache entries are subject to deletion without notice (e.g., when the system reclaims memory). The relative cost of creating an entry (which must be specified when the entry is created) may be taken into account when deleting Objects from the cache. If an estimate is not readily available, specify zero (0). Specifying CACHE_PERMANENT as the cost prevents the entry from being deleted during memory reclamation.
Object reference counts and the cache. It is important to be aware of the following: The system uses the cache to store intermediate results from modules. Thus inputs to modules often come from the cache. However:
However, Objects other than module inputs that are put into or retrieved from the cache behave differently: Once an Object is put in the cache, the system may delete it at any time to reclaim memory. This last has two consequences.
o = DXGetCacheEntry(...); ... use o ... DXDelete(o);
Failure to do so will result in a memory leak, because the Object will always have an extra reference.
o = New...; DXReference(o); DXSetCacheEntry(..., o, ...); ... use o ... DXDelete(o);
Conversely, if putting the Object in the cache is the last operation before the return, and if o is not visible outside the scope of the routine, no reference is necessary:
o = New...; ... use o ... DXSetCacheEntry(..., o, ...); return ...;
where the return statement does not return o.
Cache Routines
#define CACHE_PERMANENT 1e32
Object DXGetCacheEntry()
| Retrieve a cache entry. See DXGetCacheEntry, DXGetCacheEntryV. |
Error DXSetCacheEntry()
| Set a cache entry. See DXSetCacheEntry, DXSetCacheEntryV. |
Error DXFreeModuleId()
| Get a unique identifier for each instance of a module. See DXFreeModuleId and DXGetModuleId. |
Error DXCompareModuleId() | Returns OK if the two specified module identifiers are the same; otherwise returns ERROR. See DXCompareModuleId. |
Pointer DXCopyModuleId() | Returns a pointer to a copy of the specified module identifier. See DXCopyModuleId. |
[Data Explorer Home Page | Contact Data Explorer | Same document on Data Explorer Home Page ]