The cache functions are independent of the DBMS. That is, you can create your own tables and cache them. Two useful techniques are:
To truncate the data being cached to store only the fields in which you are interested in the cache. This allows more records to be cached in the same amount of memory.
To create tables that have changed keys from on the database. For example, you may wish to access a table by name whose key is a number. In this case, to allow it to be cached, you would declare a table where the name was the first field. If, for instance, you have a database in which orders are linked to customer records through a customer number, to display the customer name, you would replace:
customer.cust_nr = order.cust_nr; rec_fetch_main(EQUAL,&customer.l); |
with:
customer.cust_nr = order.cust_nr; if (!cache_find(&customer.l) && rec_fetch_main(EQUAL, &customer.l)) cache_post(&customer.l); |
Depending on the amount of heap available and the ratio of orders to customers, this can greatly reduce the number of DBMS accesses. This kind of code is, for example, used by PROGCOMP to reduce the number of calls to the database manage when looking up names within the formula compiler.