首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装EnyimMemcached与Couchbase服务器协同工作

安装EnyimMemcached与Couchbase服务器协同工作
EN

Stack Overflow用户
提问于 2012-06-10 13:43:57
回答 1查看 2.3K关注 0票数 1

我正试图让EnyimMemcached库与我安装在本地机器上的Couchbase社区服务器一起工作,这一点一点也不顺利。

我用在web.config

代码语言:javascript
复制
  <sectionGroup name="enyim.com">
      <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
  </sectionGroup>
代码语言:javascript
复制
  <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>

但是我在本地服务器和

代码语言:javascript
复制
var result = _client.Store(StoreMode.Add, key, val);

一直返回false

你们中有谁在使用它的时候有什么变化吗?能给我一些正确设置它的光线吗?

EN

回答 1

Stack Overflow用户

发布于 2012-07-14 10:13:47

我的配置:

代码语言:javascript
复制
<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的基本包装器

代码语言:javascript
复制
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)。如果使用单独的端口配置,也请检查是否打开它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10969190

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档