Enabling client-side caching

By default, records in SFS files are written to and read from the SFS server, and a remote procedure call (RPC) is needed whenever a record is accessed. If you enable client-side caching, however, you can improve performance because less time is needed to access records.

About this task

With client-side caching, records are stored in local memory (a cache) on the client machine and sent (flushed) to the server in a single RPC. You can specify either or both of two types of caching: read caching and insert caching:

To enable client-side caching for all the SFS files in your application, set the ENCINA_VSAM_CACHE environment variable before you run the application. To see a syntax diagram that describes setting ENCINA_VSAM_CACHE, see the related reference about runtime environment variables.

You can code a single value for the cache size to indicate that the same number of pages is to be used for the read cache and for the insert cache, or you can code distinct values for the read and insert cache by separating the values by a colon (:). Express® size units as numbers of pages. If you code zero as the size of the read cache, insert cache, or both, that type of caching is disabled. For example, the following command sets the size of the read cache to 16 pages and the size of the insert cache to 64 pages for each SFS file in the application:

export ENCINA_VSAM_CACHE=16:64

You can also specify one or both of the following flags to make client-side caching more flexible:

For example, the following command allows maximum flexibility:

export ENCINA_VSAM_CACHE=16:64:ALLOW_DIRTY_READS,INSERTS_DESPITE_UNIQUE_INDICES

To set client-side caching differently for certain files, code a putenv() call that sets ENCINA_VSAM_CACHE before the OPEN statement for each file for which you want to change the caching policy. During a program, the environment-variable settings that you make in a putenv() call take precedence over the environment-variable settings that you make in an export command.

Example: setting and accessing environment variables