Axaptapedia is now maintained by AgileCadence For more information please click here.

CacheAddMethod

From Axaptapedia
Revision as of 06:28, 19 July 2012 by Aj (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Enables caching for a display or edit method on a form. Once calculated the result of the method is passed to the client. Prior to Ax 2009, only display methods could be cached, but since that version it is also possible cache edit methods. Only methods declared on a table may be cached.

Signature[edit]

public boolean cacheAddMethod(str _methodName, [boolean _updateOnWrite])

Usage[edit]

This method should be called after the super() call in the init() method of a form datasource.

<formdatasource>.cacheAddMethod(str _methodName [,boolean _updateOnWrite = true])

_methodName
the name of the display method of the table used in this datasource
_updateOnWrite
if true, the content of the cache will be refreshed on record write.
The cache is refreshed on reread and create.

<xpp> void init() {

   super();
   this.cacheAddMethod(tableMethodStr(ProjJournalTrans, ProjName));

} </xpp>

Manually updating the cached values[edit]

If the underlying data for the display method is updated programmatically, Ax will not be aware that the control value needs to be refreshed in this case it is possible to programmatically call the cacheCalculateMethod method to force a recalculation.

Performance considerations[edit]

When caching is enabled for a display or edit method, that result of the method will be calculated on the AOS and passed through to the client with the result set. In general, this is faster than calling the method directly from the client, on demand, as it reduces client-server calls.

This makes good sense when a display method is used as part of a grid, but in other circumstances it is important to gauge whether the cost of having the method calculated every time is worth the reduction in client-server calls. An uncached display method is triggered only when the control is visible, so it can be better to not use caching for display methods bound to controls on tab pages which are rarely viewed.