Using the Cache Object
With TradePoint 3.1 came the Cache object which can be used to optimize your site extensively. To allow easy interaction with the cache object, we also supply a couple of helpful scriplet methods as described below.
Standard CachingTo utilize the cache functionality you have 2 methods you need to use with some parameters. ReferenceMiscUtils.GetCache( name, cacheMode, ignoreLocalization ) MiscUtils.SetCache(name, value, [timeout], cachemode, ignoreLocalization) Example// Try to get the cached data // write the data to the Response Clearing the cacheYou can explicitly clear a cache if you do not wish to wait for the time out. MiscUtils.ClearCache( "TheBigList", 1, true ); Fragment CachingFragment caching is used to cache complex outputs instead of having to create large strings to contain the output. Just tell the Cache to begin recording and then tell it to stop when you are done. Call BeginFragmentCache() to mark beginning of captured and cached output sequence. If there is no cached data, false is returned and recording begins and will end when EndFragment() is called. If the named fragment is already cached, true is returned and the cache is automatically written to the Response. To mark the end of a fragment, use EndFragmentCache(). This will write the newly cached fragment to the Response. Cached fragments can be nested but will only be cached in the outermost fragment, i.e. the nested fragments will be ignored but not cause errors. ReferenceMiscUtils.BeginFragmentCache(name, cacheMode, ignoreLocalization) Exampleif (MiscUtils.BeginFragmentCache('A')) Example: Caching ERP-queries in TradePointA common action in TradePoint is to cache the queries from the ERP-system (for example Dynamics NAV) and because of this caching has been added as optional parameters to the ERP-call. ReferenceMiscUtils.InvokeTP(p1, p2, p3, p4, p5, [cacheMode], [cacheMinutes])
|
Published by: Henrik Weimenhög / scriptserver.com
