Identify and apply caching mechanisms

Completed

Cached data is information that’s retrieved from an outside source, such as a website, app, or database that’s stored on your computer. Caching data decreases loading times by reducing the number of calls that are made to the database. While caching data can improve performance, it takes up space on your computer, so you should consider clearing your cache periodically.

Table caching

You can set up a table’s cache settings for finance and operations apps in the CacheLookup table property. Caching tables involves using set-based or single-record based caching. The differences between the two types are:

  • Set-based caching - Caches all groups of records at once. To implement set-based caching, you need to set the CacheLookup property to EntireTable.

    This type caches all of a table’s records after your first selection. You should avoid this type of caching for large tables because, when the cache size reaches 128 kilobytes (KB), the cache moves from memory to disk. A disk search is slower than an in-memory search and can decrease performance.

  • Single-record caching - Caches one single record at a time. Two conditions must be met to use single-record caching.

    • The CacheLookup property must be set to NotInTTS, Found, or FoundAndEmpty.

    • The record buffer disableCache method doesn't return true. Single-record caches are used on the client and the Application Object Server (AOS). If a select query is run on the client side, the system searches the client-side browser cache. If no record is found in the browser cache, finance and operations apps searches the record's AOS cache. After the system searches through the client and server caches, the data is retrieved from the database. You can also run queries on the server. These queries look in the server cache for the record and then call the database if the record isn't found. You can set up the number of records that the cache should maintain by going to System administration > Setup > System > Server configuration page in finance and operations apps.

Display method caching

In finance and operations apps, you can use display methods to show a calculated field. Whenever the form refreshes, the display method is calculated.

To improve performance, you can cache a display method, which means that it’s calculated only once when it's received from the cache.

To enable caching for a display method, add it to the init method on the form by using the following syntax:

    /// <summary> 
    /// Adding cache for display field 
    /// </summary> 
    public void init() 
    { 
      super(); 
      this.cacheAddMethod(tableMethodStr(CustTable,
         myDisplayMethod)); 
    }

Using cacheAddMethod activates the caching mechanism for the display method, and it loads into the cache. Another way to activate caching is to use [SysClientCacheDataMethodAttribute] on the display method. The method is automatically added to the caching mechanism.