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

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

复制代码
<?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>
复制代码

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

 View Code

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

 View Code

 

posted @ 2019-07-10 22:41  馨馨妙  阅读(132)  评论(0编辑  收藏  举报