SParc
SParc

Reputation: 1779

Efficiently using manual data synchronization between SQL Server Compact and WCF service

I have a web-server and a database server. There is a WCF service on the web-server and a website using it. Website requests the data from the WCF service and WCF service connects to the database server, fetches the data and returns it to the website.

To optimize this process and decrease the calls to WCF service I decided to manually cache the data on the web-server. One option I can think of was Microsoft Sync Framework. But then I realized that I have to create a sync framework by myself to achieve my objective. Because Microsoft Sync Framework does not provide any option for my kind of process. My process will be actually like this:

  1. Website requests the data.
  2. Business logic of the website checks whether it is available on the compact edition (sdf) database in the website's App_Data folder.
  3. If present, fetch the data from the compact edition.
  4. If not present, connect to WCF service and fetch the data from main database server and copy it to the compact and then fetch from compact edition.

So what I want to ask, is this technique efficient? and if YES is it there any alternative way to quickly achieve this technique? Or I have to code all of it manually?

Upvotes: 0

Views: 564

Answers (4)

Mala
Mala

Reputation: 1249

By using memcache performance can be increased.

These are the steps to implement the memcache

  1. You have to create a window service that will retrieve data from database and store in memcache in JSON format as (key value pair).

  2. For website create a handler file as an API that will retrieve data from memcache and display the result.

I have implemented this in one of my project it retrieves thousands of data in milliseconds

Upvotes: 1

Mez
Mez

Reputation: 4726

You can also use NHibernate, 2nd level caching. For more information, read this article http://www.codeproject.com/Articles/529016/NHibernate-Second-Level-Caching-Implementation. It will store data in the MemCache, and detect changes to records.

Another caching technology, is AppFabric, and you can see more details here : http://msdn.microsoft.com/en-us/library/ff383731(v=azure.10).aspx

Upvotes: 1

E.J. Brennan
E.J. Brennan

Reputation: 46859

It could work, but if it was me, and my goal was the increase performance/cache the calls between your web server and a back-end sql server, I wouldn't choose sql server compact edition for caching purposes.

Something like redis or memcached might be a more appropriate/higher performance way to increase performance of your caching layer. The compact sql server may cut down on the number of calls to your back-end server, but it might do that at the expense of slower response times overall.

Upvotes: 1

Roman Pokrovskij
Roman Pokrovskij

Reputation: 9776

It could be efficient in some circumstances, but I could propose you to use presreve data cache in local SQL Server Express instead of Compact.

The type system of SQL Server Compact is different then SQL Server. I know that EF6 support both but I would not start this journey on my own...

In any case there should be reasons why you need to work with cache throwgh RDBMS..

Upvotes: 1

Related Questions