2012-06-10 43 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)。如果您使用單獨的端口配置,請檢查它是否已打開。

相關問題