Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to create a data caching service that helps improve performance in distributed applications

$
0
0

Scenario:
In the How to connect to a remote data service instead of using a direct database connection example we described how to connect to the WCF service via console application.
If you want to take advantages of XPO data caching using this solution, the only difference is in using the ICachedDataStore interface and the CachedDataStoreService base service class that implements this interface.

Steps to implement
1.
Create a data service and console applications as described in the How to connect to a remote data service instead of using a direct database connection example.
2. Modify the service class as shown in the WCFService1\Service1 code file: use the CachedDataStoreService as base class, create a connection provide and data store.
3. Modify the web.configfile as shown in the WCFService1\web.config file.

There is no need to modify the client part since the service name has not been changed, and in addition, the “data caching domain” of our service is automatically detected by XPO.
It is easy to configure which tables should be cached and which ones shouldn't using the following code from the Service1 code file:

[C#]
DataCacheRootdataCacheRoot=newDataCacheRoot(dataStore)dataCacheRoot.Configure(newDataCacheConfiguration(DataCacheConfigurationCaching.InList,"Customer")MainDataStore=dataCacheRoot;
[VB.NET]
Dim dataCacheRoot AsNew DataCacheRoot(dataStore) dataCacheRoot.Configure(New DataCacheConfiguration(DataCacheConfigurationCaching.InList, "Customer")) MainDataStore = dataCacheRoot

This approach is useful for tables, which are frequently changed.

4. Create a data caching service based on the SqlDependency feature of the MS SQL Server. This approach is demonstrated in the WCFService2.Service1.xx file.

Important notes

If you are using an XAF client, then in the simplest case, you can just set the XafApplication.ConnectionString to the address of your data store service (http://localhost:55777/Service1.svc). Refer to the Connect an XAF Application to a Database Provider help article for more details.

See also:
How to connect to a remote data service instead of using a direct database connection
How to implement a distributed object layer service working via WCF
How to connect to a remote data service from a Silverlight application

How to connect to remote data store and configure WCF end point programmatically


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>