Storage Locations provide FOX with a standard mechanism for accessing/updating units of data. They are a definition of how and where data is stored and accessed. They differ from fm:query definitions as Fox decides where, when, and how to use the SQL/DML defined within the Storage Location.
The following code shows what might be included within a storage location:
<fm:storage-location name="name">
<fm:cache-key string="module name :bind">
<fm:using>bind xpath</fm:using>
</fm:cache-key>
<fm:new-document>
<fm:root-element>root</fm:root-element>
</fm:new-document>
<fm:database>
<fm:query>
<fm:sql>
sql statement with :bind
</fm:sql>
<fm:using>bind xpath</fm:using>
</fm:query>
<fm:insert>
<fm:sql>
dml statement with :bind
</fm:sql>
<fm:using>bind xpath</fm:using>
</fm:insert>
<fm:update>
<fm:sql>
dml statement with :bind
</fm:sql>
<fm:using>bind xpath</fm:using>
</fm:update>
</fm:database>
</fm:storage-location>
A global caching mechanism is used across the FOX System. Data is loaded into the memory cache bucket, which is identified using a cache key (I.E. the name of the bucket). All operations are performed on the data held in the memory cache as this provides best performance. Because the caching mechanism is global across FOX, two different user sessions, running different modules can access a common unit of data - simply by addressing the same bucket (I.E. using the same cache key). This means both users can benefit from seeing the common data consistently and quickly, whilst system memory is optimised as only one version of the data is held.
You can have multiple storage location definitions within a module, but each one should have a unique cache key and name.
Across modules, the cache key must be unique for discrete data. Common data can however be reused by engineering a repeatable cache key.
An example of a storage location for a module called MOD012X that had no variables passed into it and would use a unique bind variable is:
This ‘:1’ is replace by a unique value populated by FOX
For the same module, but with a variable called ID passed into the module, you would use the following code to declare the storage location:
<fm:storage-location name="main">
<fm:cache-key string="MOD012X:1">
<fm:using>:{params}/ID</fm:using>
</fm:cache-key>
<fm:new-document>
<fm:root-element>ROOT</fm:root-element>
</fm:new-document>
</fm:storage-location>