IFS Applications are designed to use views in the client to retrieve data and as the client often needs more data from other entities, the views uses PL/SQL functions to get that information. This is done either by Get_methods accessed through a primary key (PK) in the select list or in the where clause. The Get_methods are executed at least once for each row and are fetched from the database, often with calling columns as parameters. If instead the last record fetched is saved, and a check is added to see if it is the same record that is requested again, then the saved record could be passed back to the client. If such functionality existed then a database call (query) isn't necessary and that is exactly what the Micro Cache provides.
The Micro Cache is a runtime cache where the data is saved temporarily. By using the Micro Cache the buffer gets can be reduced significantly, but due to some limitations it should be implemented with care.
The Micro Cache is also an Oracle session cache, so each user logged on to Oracle has it's own cache. This means that if ten users access the same record in the same entity time after time, then by using the same primary key (PK) for a method they will use their own cache. If the first user updates the entity his cache will be flushed, but the other users caches are not flushed. This will lead to that they will retrieve the wrong data until they have read a new record and done a new fetch again. The cache is also flushed if one user logs out and that Oracle session is acquired by another user. In order to minimize this problem a timestamp together with the primary key could be used, then the cache is flushed if the time has past the limit. IFS EE APF pages, the cache is flushed after each client call to the server but not in other clients such as IFS Aurena / IFS EE Feature pages or Mobile clients.
The Micro Cache Array is an extension of Micro cache implementation. The only difference with Micro Cache is, Micro Cache array can store multiple records instead of a single record. When the array is filled with records, one item is randomly removed at the next request.
Some good examples of when to use Micro Cache are as follows:
When executing the query below the database first fetches all Order_Head rows and then executes Get_Cust_Name method for each row. Since this query is ordered by Customer_No it is most likely that the same Customer_No is used several times, before changing the Customer_no. If the last record fetched is saved, then there is a check to see if it is the same record that is being requested again. If it is, then the saved record is passed back to the client. Then a call (query) to the database isn't necessary.
Micro Cache Array is preferred for most of the scenarios where Micro Cache is applicable & more than one record of the LU is referred in an application flow. But if this number of records is in hundreds or even higher, then there may be hardly any advantage implementing either Micro Cache or Micro Cache Array for that LU.
Examples of when not to use either Micro Cache or Micro Cache Array:
To get the Micro Cache / Micro Cache Array implementation to work, you only need to add a codegen property in the entity model.
Micro Cache:
When to code has been generated a few variables will be declared. A public record holding the cached values, a number to be used for the timestamp and an id for the cached Primary Key. If more than one Primary Key exists then more variables needs to be declared.
The Update_Cache_ method in the Get_method will be generated and used instead of a cursor and then return the value from the Micro Cache record.
The Invalidate_Cache___ method will be generated into Update___ and Delete___ to reset the cache in case the record is modified or removed.