WCF Rest Services + Web Caching ( for non Microsoft SQL Connection Case )

WCF Rest Services + Web Caching ( for non Microsoft SQL Connection Case )

   IService.cs
 
   using System;
   using System.Collections.Generic;
   using System.Linq;
   using System.Runtime.Serialization;
   using System.ServiceModel;
   using System.ServiceModel.Web;
   using System.Text;
   using System.ServiceModel.Activation;
 
   namespace SoccerRest
   {
      [ServiceContract]
      public interface IService
      {
 
         … …
 
         [OperationContract]
         [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "team")]
         List<TEAM> GetAllTeam();
 
         [OperationContract]
         [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "teamjson")]
         List<TEAM> GetAllTeamJson();
 
         [OperationContract]
         [AspNetCacheProfile("CacheData")]
         [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "full")]
         List<LEAGUE_ITEM> GetFullList();
 
         [OperationContract]
         [AspNetCacheProfile("CacheData")]
         [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "fulljson")]
         List<LEAGUE_ITEM> GetFullListJson();
 
      }
 
      … …
 
   }
 
   Service.svc.cs
 
   using System.Collections.Generic;
   using System.ServiceModel;
   using System.ServiceModel.Web;
   using Oracle.DataAccess;
   using Oracle.DataAccess.Client;
   using System.Data;
   using System.ServiceModel.Activation;
 
   namespace SoccerRest
   {
      [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
      public class Service : IService
      {
 
      … …
 
      [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "team")]
      public List<TEAM> GetAllTeam()
      {
         … …
      }
 
      [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "teamjson")]
      public List<TEAM> GetAllTeamJson()
      {
         … …
      }
 
      [AspNetCacheProfile("CacheData")]
      [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "full")]
      public List<LEAGUE_ITEM> GetFullList()
      {
         … …
      }
 
      [AspNetCacheProfile("CacheData")]
      [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "fulljson")]
      public List<LEAGUE_ITEM> GetFullListJson()
      {
         … …
      }
 
      … …
 
      }
   }
 
   web.conf
 
   <?xml version="1.0" encoding="UTF-8"?>
   <configuration>
 
      <system.web>
         <compilation debug="true" targetFramework="4.0" />
         <caching>
            <outputCache enableOutputCache="true"/>
            <outputCacheSettings>
               <outputCacheProfiles>
                  <add name="CacheData" duration="120" varyByParam="*" />
               </outputCacheProfiles>
            </outputCacheSettings>
         </caching>
      </system.web>
      <system.serviceModel>
 
         <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
         … …
 
      </system.serviceModel>
 
   </configuration>
 

 
Reference : There is another solution for WCF Restful Caching with ( Microsoft SQL ) SQL Caching.