What ChannelFactory caching in the WCF 4.5 framework is.
Today I explain what ChannelFactory caching in the WCF 4.5 framework is. With the help of this new feature in .NET we can cache the service instance. Microsoft has introduced a new property for the ClientBase<T> class; the property name is CacheSetting. We can set the cachesetting with the help of the CacheSetting enum.
Here are the values of the Enum:
Name
Description
System.ServiceModel.CacheSetting.AlwaysOn
All instances of Client will use the same channel factory.
System.ServiceModel.CacheSetting.AlwaysOff
All instances of the Client would use different channel factories. This is useful when each endpoint has different security requirements and it makes no sense to cache.
System.ServiceModel.CacheSetting.Default
Here is sample code for the Default CacheSetting:
class Program { static void Main(string[] args) { ClientBase<IService1>.CacheSetting = System.ServiceModel.CacheSetting.Default; using (ServiceReference1.Service1Client client = new Service1Client()) {
} } }
Here is sample code for the AlwaysOn CacheSetting:
static void Main(string[] args){
ClientBase<IService1>.CacheSetting = System.ServiceModel.CacheSetting.AlwaysOn;using (ServiceReference1.Service1Client client = new Service1Client()) { }}
Here is sample code for the AlwaysOff CacheSetting:
static void Main(string[] args){ ClientBase<IService1>.CacheSetting = System.ServiceModel.CacheSetting.AlwaysOff;
using (ServiceReference1.Service1Client client = new Service1Client()) { }}
Reference from
http://msdn.microsoft.com/en-us/library/hh314046%28v=vs.110%29.aspx
http://msdn.microsoft.com/en-us/library/system.servicemodel.cachesetting%28v=vs.110%29.aspx
.NET Standard-9011