Caching in Livelink OScript

Recently one of my colleagues blogged a brief introduction on how to use caching in Livelink, as a follow on I'm going to show how to Update an existing cache object and how to Delete an existing cache object to round off the article.

Firstly updating an existing cache object can be done just as easily as the rest of the work with cache :

				// declare a cache id - in real life we would have this from somewhere else
				Integer cacheID=1234
				// load the data from the cache to begin with into the Assoc
				Assoc myDataFromCache = $LLIAPI.CacheUtil.Load (prgCtx,cacheID).ObjectValue

				// update the values
				myDataFromCache.newValue="abc"

				// Save the updated Assoc back to the cache
				Assoc updateCacheResult=$LLIApi.CacheUtil.Update(prgCtx, cacheID, myDataFromCache )

				// if the cache update failed
				if (!updateCacheResult.OK)
				    // write out to the log the value of errMsg if provided, otherwise apiError if provided, otherwise a default error message
				    (isDefined(updateCacheResult.errMsg))
				        echo(updateCacheResult.errMsg)
				    elseif ((isDefined(updateCacheResult.apiError)))
				        echo(updateCacheResult.apiError)
				    else
				        echo("error deleting cache"))
				    end
				end
			
Later when we have finished with our Cache object we need to delete the cache object :
				// declare a cache id - in real life we would have this from somewhere else
				Integer cacheID=1234

				// Delete the cache
				Assoc deleteCacheResult=$LLIApi.CacheUtil.Delete(prgCtx, cacheID)

				// if the cache deletion failed
				if (!deleteCacheResult.OK)
				    // write out to the log the value of errMsg if provided, otherwise apiError if provided, otherwise a default error message
				    (isDefined(deleteCacheResult.errMsg))
				        echo(deleteCacheResult.errMsg)
				    elseif ((isDefined(deleteCacheResult.apiError)))
				        echo(deleteCacheResult.apiError)
				    else
				        echo("error deleting cache"))
				end
			
More information can be found in the Builder On Line Help - <builder virtual directory>/documentation/moddevguide/mdg_cacheutil.html showing a worked example and more information.
Website Designed by Adservio Consulting Valid HTML 4.01 Strict    Valid CSS!    Level A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0