Sunday, October 24, 2010

Using AppFabric (Velocity) Caching API in WCF Service.

One of the best way to improve Application performance is to Cache Data which is frequently Accessed or Retrieved from Database so that we can  reduce the trip to Database and we can minimize or avoid the DB operations. MS Velocity offers in-memory caching.  In this blog I am going to show how to cache the some of the frequently access the data .

In this Exercise I am going to use  MS Free Database Chinook (Album ) as my data model. This Database has bunch of tables but I wanted to cache Customer and Album Tables. Here I am going to create WCF Service which expose to operations which returns list of  All Albums and All Customers.  Before creating WCF service I wanted to give brief introduction on  the Caching API’s we are going to use. Here I am going to use the following two Caching Services APIs

image

To Add Reference to our WCF project we need select it from  GAC ( Global Assembly Cache ). we can not add reference like other Assembly .  GAC is nothing but a  windows  file Folder which is created when you install .NET Framework and its  located  @ C:\Windows\Assembly  to add reference

image 

Here is the Caching API’s Classes and Methods which we will be using in our code.

image 

Here I am going to define the WCF Service which exposes two operations  GetAllAlbums and GetAllCustomers 

image

Here is the Caching Library implementation

image

 

image

using PowerShell Cmdlet we can verify our cache services  first let is check our Cache Host using  “Get-CacheHost”

image 

Get-Cache will displays the Cache Names

image

Get-CacheStatistics will give you the details about Cached item and Request Count etc..

image

Next Blog post we will see how to set Caching services in Web.config

Nandri( Thanks)

SreenivasaRagavan.

Saturday, October 23, 2010

Windows Server AppFabric–Caching Service

Windows AppFabric is set of technologies which offer to Hosting Services and Caching Services. In this blog post I am going show how to Install and Use  Caching Services. Windows AppFabric offers in memory caching with Distributed and Multi cluster supports . Windows AppFabric  aka “Velocity”.

There is two way you can install Windows AppFabric

1) Using Microsoft Web installer[http://www.microsoft.com/web/gallery/install.aspx?appsxml=http://www.microsoft.com/web/webpi/2.0/EnterpriseProductList.xml&appid=AppFabric]

2) You can download the bits from the following URL and Install http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=467e5aa5-c25b-4c80-a6d2-9f8fb0f337d2

Once you download and Run the Installer when you get to this screen where you will be configuring  Caching Service.

image

After installing you will the following Features added to IIS Manager

image

First we need to set Caching Service Configuration provider here you have two options one is  XML provider another options is  SQL Server .  This is just to store Caching Services Details like how many machines (Servers) in the cluster and their port numbers as shown below.  I like to mention here one thing  Windows AppFabric services wont store any Cache data in Database.

image

Here I choose XML is my Service Configuration provider so the configuration file stored in Network file share . Once you successfully installed. we can verify the Installation of Caching Services.   First Launch the  Power Shell Admin tool for Cache Services. 

Now Type “Get-Cachehost” this command will tells the service Status .

image

Here I have created two CacheName  Ragavan & Sreeni

image

image

To got Help for  all Cmdlet you can type Get-Help *

image

Next Blog post  we are going to use Caching API to store and retrieve data from Cache .

Thanks (Nandri)

Sreenivasa Ragavan

Sunday, October 3, 2010

MSDN Magazines

I Like to read MSDN Monthly Magazine and having a digital copy  in locally makes me great.  If you feel the same way I do  please point your browser to the following URL and Download  New and Old Magazines 

http://msdn.microsoft.com/en-us/magazine/ee412244.aspx

image

Nandri(Thanks)

SreenivasaRagavan