dotConnect for Salesforce Documentation
Managing Cache

The Cache property of SalesforceConnection is used for managing cache for or objects of this connection. This property is of SalesforceCache type. This class provides a set of methods for creating, enabling, disabling, altering, and deleting cache for or objects, and getting cache state.

Creating Cache

To create a cache for an object, use one of the overloads of Create method of the SalesforceCache class. One of the overloads accepts a SalesforceCacheItem instance as a parameter. This class represents cache settings for a single or object. Create an instance of such class and set the following fields of it:

Or you may use another overload that accepts these settings as the corresponding parameters.

Altering Cache Settings

After creating, you may change the cache parameters using the one of the Alter method overloads. You can change cache settings separately with some overloads or alter all of them wit one call using either an overload, accepting SalesforceCacheItem instance or all settings as separate parameters.

Disabling and Enabling Cache

Cache can be enabled or disabled with the Enable and Disable methods of the SalesforceCache, accepting either an object name or a SalesforceCacheItem instance as their parameter. When the cache is disabled, its data is preserved, however all queries to the cached object retrieve its data from or and don't use the cache.

Refreshing Cache

Cache is refreshed automatically each refresh interval, however, you can refresh it manually with the Refresh method of SalesforceCache. If refresh interval is set to 0 or negative number, this means that cache is never gets out-of-date and is not refreshed automatically, and the Refresh method is the only way to refresh it.

Retrieving Cache Settings

Cache settings for an object can be retrieved with GetCacheItem method of SalesforceCache. You may get the names of the objects, for which cache exists, using GetCachedTables method of SalesforceCache.

Modifying Data

dotConnect for Salesforce cache is a write-through one. When you modify data, this modifications are immediately applied to the remote data and then they are applied to the cache. If dotConnect for Salesforce cannot update the cache because some of the modified data may have been generated by or, for example, if there are calculated fields, or some field are not present in the INSERT statement and should take their default values, it queries the modified data from it, and then updates the cache.

Dropping Cache for Object

To drop the cache use the the Drop method of SalesforceCache, which accepts the name of the table to drop the cache for or a SalesforceCacheItem instance as a parameter. After the cache is dropped, queries to this table will request its data from or

See Also

Cache Overview