Tags:
view all tags
<h1>The Use of Cached Files</h1> <p>APPX 4.1 introduces the ability to create and access a cached instance of a file in memory.</p> <p>The CREATE, OPEN, SCRATCH, and IF EXIST statements have been modified to include new syntax to support this feature:<i><font face="Arial"/></i></p> <h5>CREATE statement:</h5> <p>The CREATE statement can now create and open a cached instance of a file. Specifying a CACHE option other than 'NONE' causes a cached instance of a file to be created in memory and opened instead of the normal disk instance of the file. The value of the CACHE option determines how the cached instance of the file is populated.</p> <p>If --- NEXT DATABASE is specified for a CREATE statement which creates a cached file, then the value of next database determines the source database for loading the cache. Otherwise the current database determines the source of the file used to load the cache. </p> <dir><b><pre>CREATE ___ ________ SHARE? _ FAIL _ CACHE _______ (1) (2) (3) (4) (5)</pre> </b><dir><b/><font size="2"> <p>(1) Application ID<br/>(2) File Name<br/>(3) Share Y/N?<br/>(4) Fail Type<br/>(5) Cache type { blank || NONE, LOAD, AUTO, NOLOAD || NO LOAD } </p></font></dir><u><font face="Arial" size="2"> </font></u><font face="Arial" size="2"><p><u>CACHE</u>: </p> </font><dir><font face="Arial" size="2"> </font><p><font face="Arial" size="2">NONE - Create and open the file as a normal, non-cached file.<br/>NO LOAD - Create and open the cached instance of the file but do not load any records into the cache file.<br/>LOAD - Create and open the cached instance of the file and load cache file from the disk instance of file.<br/>AUTO - (Currently same as LOAD) Create and open the cached instance of the file. Dynamically populate the cache from the disk instance of the file as records are individually read.</font><font size="4"><font face="Times New Roman"> </font></font></p></dir></dir> <h5><br/>OPEN statement:</h5><b><i><font face="Arial"> </font></i></b><i><font face="Arial"/></i><font face="Arial"/><dir><font face="Arial"><i><b/></i></font> <p>A parameter added to the OPEN statement allows it to open either the cached instance of a file or the disk instance of the file. </p> <p>If CACHE=Y and the cached instance of the file does not exist, then the OPEN statement will fail. So, a CREATE statement must be used to create the cached instance of a file before the OPEN statement can be used to open it. </p> <p>If --- NEXT DATABASE is specified in conjunction with CACHE=Y, then --- NEXT DATABASE is cleared and ignored.<font size="5"> </font></p><pre><b>OPEN ___ ________ SHARE? _ FAIL _ CACHE? _ (1) (2) (3) (4) (5)</b></pre><b> </b><dir><b/><font size="2"> </font><p><font size="2">(1) Application ID<br/>(2) File Name<br/>(3) Share Y/N?<br/>(4) Fail Type<br/>(5) Cache Y/N?</font><font size="3"> </font></p></dir></dir> <h5><br/>SCRATCH statement:</h5> <dir> <p>A parameter added to the SCRATCH statement allows it to scratch either the cached instance of a file or the disk instance of the file. If --- NEXT DATABASE is specified in conjunction with CACHE=Y, then --- NEXT DATABASE is cleared and ignored. </p><pre><b>SCRATCH ___ ________ FAIL _ CACHE? _ (1) (2) (3) (4)</b></pre><b> </b><dir><b/><font size="2"> </font><p><font size="2">(1) Application ID<br/>(2) File Name<br/>(3) Fail Type<br/>(4) Cache Y/N?</font><font face="Courier New" size="1"> </font></p></dir></dir> <h5><br/>CLOSE statement:</h5><b><i><font face="Arial"> </font></i></b><i><font face="Arial"/></i><font face="Arial"/><dir><font face="Arial"><i><b/></i></font> <p>The CLOSE statement closes the currently opened instance of a file, either disk or cache.</p></dir> <h5>IF EXIST statement:</h5><b><i><font face="Arial"> </font></i></b><i><font face="Arial"/></i><font face="Arial"/><dir><font face="Arial"><i><b/></i></font> <p>The IF EXIST statement <font color="#ff0000">WILL BE modified in the 2nd beta release</font> to allow its use on either the disk or cache instance of a file.</p></dir> <h5><br/>DD Specification:</h5><font face="Arial"> <dir><font color="#ff0000"> <p>The 2nd beta release will also include a specification in the DD which will allow you to specify a CACHE option:</p> <dir><pre>NONE LOAD AUTO</pre></dir> </font><p><font color="#ff0000">These options will have the same functionality as the CREATE statement and will eliminate the need to use a CREATE statement in those cases where a file would normally be opened as a cached file.</font><font face="Arial" size="4"/></p></dir><font face="Arial" size="4"> <p/></font></font> <h5>Notes: </h5><font face="Arial"><font face="Arial" size="4"><i><b> </b></i></font><ul><font face="Arial" size="4"><i><b/></i></font> <p>1) Like memory files, there can be only a single instance of a cached file. There is no separate instance of a cached file for each database. </p><p>2) Once you have opened the cached instance of a file, all I/O which follows will reference the cached instance of the file, not the disk instance. </p><p>3) If you execute a CREATE statement with CACHE=NO LOAD, then you can load the file yourself, perhaps with a subset of the records. One possible use of this would be to effectively constrain a DLU. See example below. </p><p>4) If you rewrite, delete, or write records to the cached instance of the file, the disk instance of the file will not be updated. If the disk instance of the file changes after you create and load the cached instance of the file, the cached instance of the file will not automatically include these changes. </p><p>5) Cached files were conceived of as a performance enhancement for "read only" files which are stored as tables in databases. However, they should prove to be useful in many other applications as well! </p></ul> <p align="right"><font face="Arial" size="4"> </font></p><p/></font> <h5>Example:</h5><font face="Arial"><pre> * This code creates a cached instance of the SALESREP file and * loads it with the "Inside" salesreps * * Create a cache instance of the SALESREP file CREATE CCA SALESREP SHARE? Y FAIL 0 CACHE NOLOAD * Open the disk instance of the file OPEN CCA SALESREP SHARE? Y FAIL 0 CACHE? N * Read all of the SALESREP records BEG READ CCA SALESREP HOLD 0 KEY IS SALESREP SALESPERSON * Add only inside salesreps to the cache instance of the file IF CCA SALESREP INSIDE EQ Y T OPEN CCA SALESREP SHARE? Y FAIL 0 CACHE? Y T WRITE CCA SALESREP FAIL 0 T OPEN CCA SALESREP SHARE? Y FAIL 0 CACHE? N * END READ CCA SALESREP * Close the disk instance and open the cached instance - all * references in the process will now use the cached instance OPEN CCA SALESREP SHARE? Y FAIL 0 CACHE? Y </pre> -- Main.JoeOrtagus - 2012-01-18
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r1 - 2012-01-18
-
JoeOrtagus
Home
Site map
Main web
MedicaidBilling web
Sandbox web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Edit
Attach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback