Search Wiki:

WCF AppFabric Caching Behavior Sample

Download Microsoft.ServiceModel.Samples.Caching.v1
Watch endpoint.tv - WCF AppFabric Caching Behavior Sample

This sample demonstrates how you can use a WCF Operation Behavior to implement server side caching with AppFabric Cache.  This page will invoke a contract that uses the CacheResultAttribute to cache the result of the GetSampleData method for 2 minutes.

   [ServiceContract]
    public interface ISampleService
    {
        [OperationContract]
        [CacheResult(Minutes=2)]
        SampleData GetSampleData(SampleDataRequest request);
    }

Try It

  1. Start AppFabric Caching
  2. Set a breakpoint in the SampleDataRepository.Get method
  3. Start debugging
  4. Enter a key between 1 and 20
  5. The first time the debugger will break in the repository
  6. Enter the same key a second time
  7. A response will be returned without breaking in the repository code because the request was served from the caching behavior
Last edited Jan 17 2011 at 1:13 PM  by RonJacobs, version 6
Comments
ryancrawcour wrote  Dec 7 2010 at 12:41 AM  
this is brilliant! thank you so much!

RagingKore wrote  Jun 17 2011 at 7:43 PM  
Pure awesomeness!!! And the next step shoud probably be the impmentation of cache configuration by operation and parameter values! :)

ChrisL wrote  Aug 10 2011 at 12:09 AM  
Will this be coming to workflow foundation?!

Updating...
Page view tracker