2012-06-10 44 views
0

我试图在没有运气的情况下使EnyimMemcached库与我在本地计算机上安装的Couchbase Community server一起工作。设置EnyimMemcached以与Couchbase服务器一起工作

我使用web.config

  <sectionGroup name="enyim.com"> 
    <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" /> 
    </sectionGroup> 
<enyim.com> 
    <memcached protocol="Binary"> 
     <servers> 
     <add address="localhost" port="8091" /> 
     </servers> 
     <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" deadTimeout="00:02:00" /> 
     <authentication type="Enyim.Caching.Memcached.PlainTextAuthenticator, Enyim.Caching" userName="Administrator" password="1234" /> 
    </memcached> 
    </enyim.com> 

,但我不断收到本地服务器上没有命中和

var result = _client.Store(StoreMode.Add, key, val); 

不断返回false

是否有任何改变,你们任何人都可以使用它,并且可以告诉我一些正确设置它的灯光?

+0

您是否使用CouchbaseClient? - http://www.couchbase.com/develop/net/current。 –

+0

不,我想用'Enyim.Caching.Memcached'来代替云,因此我想继续在本地计算机上工作,但当前的Memcached服务器不允许在Amazon EC2域以外的连接。 – balexandre

+0

CouchbaseClient是Enyim.Caching中MemcachedClient的一个子类,因此Couchbase客户端层确实只负责Couchbase的特定设置。所有缓存调用实际上都是通过Enyim代码执行的...... –

回答

1

我的配置:

<sectionGroup name="enyim.com"> 
     <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" /> 
</sectionGroup> 
... 
<enyim.com> 
    <memcached> 
    <servers> 
     <add address="127.0.0.1" port="10001" /> 
    </servers> 
    <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:10:00" deadTimeout="00:02:00" /> 
    </memcached> 
</enyim.com> 

为的System.Web.Caching.Cache

public class MemcachedCache : ICache 
{ 
     private MemcachedClient cache; 

     private TimeSpan _timeSpan = new TimeSpan(
      Settings.Default.DefaultCacheDuration_Days, 
      Settings.Default.DefaultCacheDuration_Hours, 
      Settings.Default.DefaultCacheDuration_Minutes, 0); 

     public MemcachedCache() 
     { 
      cache = new MemcachedClient(); 
     } 
     /// <summary> 
     /// Gets a cache object based on the cache_key. 
     /// </summary> 
     /// <param name="cache_key"></param> 
     /// <returns></returns> 
     public object Get(string cache_key) 
     { 
      return cache.Get(cache_key); 
     } 
     /// <summary> 
     /// Override to allow expiration at a specific date/time and a priority level. 
     /// </summary> 
     /// <param name="cache_key"></param> 
     /// <param name="cache_object"></param> 
     /// <param name="expiration"></param> 
     /// <param name="priority"></param> 
     public void Set(string cache_key, object cache_object, DateTime expiration, CacheItemPriority priority) 
     { 
      cache.Store(StoreMode.Set, cache_key, cache_object, expiration); 
     } 

     /// <summary> 
     /// Override to cache for a specified amount of time and a priority level. 
     /// </summary> 
     /// <param name="cache_key"></param> 
     /// <param name="cache_object"></param> 
     /// <param name="expiration"></param> 
     /// <param name="priority"></param> 
     public void Set(string cache_key, object cache_object, TimeSpan expiration, CacheItemPriority priority) 
     { 
      cache.Store(StoreMode.Set, cache_key, cache_object, expiration); 
     } 
} 

基本包装为您的配置还检查是否所有的端口打开(8091,8092)。如果您使用单独的端口配置,请检查它是否已打开。

相关问题