且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Memcached通用类(基于enyim.com Memcached Client)

更新时间:2022-08-15 13:46:11

一.如果用官方提供的方法,在web.config里面配置好了各个参数和服务器IP。如下图:

Memcached通用类(基于enyim.com Memcached Client)
Memcached通用类(基于enyim.com Memcached Client)
<?xml version="1.0"?>
<configuration>
  <configSections>   
     <sectionGroup name="enyim.com">
      <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching"/>
    </sectionGroup>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> 
  </configSections>
 <enyim.com> 
    <memcached protocol="Text">
      <servers> 
        <add address="127.0.0.1" port="11211" />
        <add address="127.0.0.1" port="11212" />
        <add address="127.0.0.1" port="11213" />
        <add address="127.0.0.1" port="11214" />
      </servers>
      <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:05" deadTimeout="00:02:00" />
    </memcached>
  </enyim.com> 
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
</configuration>
Memcached通用类(基于enyim.com Memcached Client)
Memcached通用类(基于enyim.com Memcached Client)

则使用该通用类即可,组件自动调用web.config里面的配置。

Memcached通用类(基于enyim.com Memcached Client)

二.如果不想在web.config配置,那就使用下面的通用类。

Memcached通用类(基于enyim.com Memcached Client)
分类: ASP.NET,Memcached

本文转自左正博客园博客,原文链接:http://www.cnblogs.com/soundcode/p/4020878.html,如需转载请自行联系原作者