Understanding Business Connectivity Services Client Cache to Optimize Your Solutions

SharePoint 2010

Last modified: January 07, 2010

Applies to: SharePoint Server 2010

Business Connectivity Services (BCS) uses a cache to store a copy of the external data required by the BCS solutions deployed on the Office client. The cache enables external data to be automatically copied on the client and managed for real-time access, with automatic data synchronization between the cache and the external application. The benefits of using a cache on the client to store data locally from the external data source are obvious:

  1. Increases application throughput: Once the data is stored in the cache, future use can be made by accessing the cached copy rather than re-fetching the original data from the external data source where the data is expensive to fetch.

  2. Supports disconnected scenarios: Users can continue to work with the BCS solutions to manipulate external data seamlessly and efficiently even when the connectivity to the external data source is slow, intermittent, or not available.

The client cache is implemented as a per-user SQL CE database which is encrypted with EFS. Note that you should not edit the database directly in any way. It is not supported by Microsoft. You should instead use the Cache object model to get access to the cache.

The unit of storage in the cache is entity instance. A process called BCSSync.EXE runs on the client and provides automatic cache refresh and data synchronization of the entity instances. Whenever an operation such as Read, Create, Update, or Delete is performed on an entity instance in the client application, calls are not routed directly to the external application (LobSystemInstance). Instead, the operations are stacked in the operation queue, a location in the cache, and then executed one by one depending on the availability of the external application. For details on how cache handles each operation, see the rest of the topics in this section. The sync process also tries to maintain fresh data in the cache by refreshing it from the external application at certain intervals. The exact time at which the cache will be refreshed cannot be predicted and depends on the cache refresh interval (ExpireAfter) set by the user, the availability of the external data source, and several other factors. These are discussed in detail in the following sections.

As a developer, you should understand how the business data cache works for two major reasons:

  1. To improve throughput of your BCS solution by understanding how to model your application for maximum throughput and optimize the use of cache in your solution.

  2. To resolve cache synchronization errors when there is conflict or errors in external data.

To make it simple to understand, in this document, let’s consider a simple BCS solution deployed on the client by connecting a Customers external list to Microsoft Outlook. Let’s also assume that this external list is backed by the GetCustomersByID SpecificFinder and that three views have been defined for this entity in the model using the Finder, GetCustomers with the filter values, State="CA", State="WA", and State= "NJ" to view customers in California, customers in Washington, and customers in New Jersey.