skip to main content
Using the driver : Client-Side Caches : Modifying a Cache Definition : Refreshing Cache Data
  

Try DataDirect Drivers Now
Refreshing Cache Data
To prevent the data in a cache from becoming out of date, the driver periodically refreshes the cache data with data from the remote data source. To minimize the amount of data that needs to be moved when a cache is refreshed, and the time required to refresh it, the driver checks to see which records in the remote table have been added, modified, or deleted since the last time the cache was refreshed. The driver retrieves only data for added or modified records and removes only deleted records from the cache. Your application can explicitly refresh the cache or the driver can refresh the cache automatically.
You can refresh a cache explicitly at any time by using the Refresh Cache statement (see Refresh Cache (EXT)). The Refresh Cache statement can also be used to perform a Clean (complete) refresh in addition to the standard optimized refresh. A Clean refresh discards all the data from the cache and repopulates it with data from the remote data source.
The driver also can refresh a cache automatically. When you create a cache, one of the attributes that you set is the refresh interval for the cache. During each cache query, the driver checks to see whether the time elapsed since the last refresh has exceeded the refresh interval for the cache. If it has, the driver refreshes the cache before satisfying the query.
Update operations to a table that is cached can trigger the driver to refresh the cache automatically. The caches maintained by the Salesforce driver are write-through caches. For any operation that modifies data in a table that is cached, the driver performs the operation on the remote data first and then updates the cache. The driver may not be able to update the cache with all modifications because some of the modified data may have been generated by the remote data source. For example, if a row is inserted but a value for all columns in the row is not required, any default values generated by the remote data source for columns not specified in the Insert statement would not be set in the cache. Because the driver cannot reflect all the changes made when a cached table is modified, it sets the cache state to dirty. When a cache state is dirty, the next query that attempts to fetch data from that cache causes the driver to refresh the cache before the fetch operation is performed. This allows the fetch to access the values populated by the remote data source.
The state of a cache can be viewed by selecting the STATUS column of the INFORMATION_SCHEMA.SYSTEM_CACHES table. See "SYSTEM_CACHES Catalog Table" for more information.