Using the Same Cache in Multiple Business Functions or Forms

If the same cache is required for two or more business functions or forms, call jdeCacheInit or jdeCacheInitEx in the first business function or form, and add data to it. After exiting that business function or form, do not call jdeCacheTerminate because this removes the cache from memory. Instead, in the subsequent business functions or forms, call jdeCacheInit or jdeCacheInitEx again with the same index and cache name as in the initial call to jdeCacheInit or jdeCacheInitEx. Because the cache was not terminated the first time, JDECACHE looks for a cache with the same name and assigns that to you. Because the cache already has records in it, you do not need to refresh it. You can proceed with normal cache operations on that cache.

If a cache is initialized multiple times across business functions or forms, use jdeCacheTerminateAll to terminate all instances of the cache that were initialized. The name of the cache that corresponds to the HCACHE passed to this API will be used to determine the cache to destroy. Use this API when you do not want to call jdeCacheTerminate for the number of times that jdeCacheInit or jdeCacheInitEx was called. If you move from one form or business function to another when you initialize the same cache across business functions or forms, you will lose the HCACHE because it is a local variable. To share the same cache across business functions or forms, do not call jdeCacheTerminate when you exit a form or business function if you intend to use the same cache in another form or business function.