1

I'm trying, without luck at all, to make the EnyimMemcached library work with Couchbase Community server that I have installed on my local machine.

I'm using in 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>

but I keep getting no hits on the local server and the

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

keeps returning false.

Is there any change that any of you work with it and can show me some light on setting it up correctly?

balexandre
  • 73,608
  • 45
  • 233
  • 342
  • Are you using the CouchbaseClient? - http://www.couchbase.com/develop/net/current. – John Zablocki Jun 11 '12 at 13:37
  • 1
    no, I wanted to use `Enyim.Caching.Memcached` instead as that's what I have in the cloud, and I wanted to still work on my local machine, but the current Memcached server does not allowed connections outside Amazon EC2 domain. – balexandre Jun 11 '12 at 16:31
  • CouchbaseClient is a subclass of MemcachedClient in Enyim.Caching, so the Couchbase client layer really just takes care of the Couchbase specific setup. All of your caching calls would actually be performed through the Enyim code... – John Zablocki Jun 12 '12 at 16:30
  • I use memcache from couchbase server 2.0 through Enyim.Caching, but I run my memcache bucket on separate port (without password authentication). I can provide my config later if you need. – m03geek Jul 13 '12 at 21:03
  • @Alex would be nice if you could share your configuration... – balexandre Jul 13 '12 at 21:18
  • Try something like: In the morning (now 0:30) I'll connect to my server and provide my config. – m03geek Jul 13 '12 at 21:34

1 Answers1

1

My config:

<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>

Basic wrapper for 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);
        }
}

For your configuration also check if all ports opened (8091, 8092). If you use separate port configuration also check if it is opened.

m03geek
  • 2,508
  • 1
  • 21
  • 41