无法使Enyim.Caching MemcachedClient与Couchbase一起使用 [英] Unable to get Enyim.Caching MemcachedClient to work with Couchbase

查看:121
本文介绍了无法使Enyim.Caching MemcachedClient与Couchbase一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到Couchbase为他们的内存缓存服务器提供了客户端,但是我正在尝试使enyim.caching客户端正常工作.

I realize that Couchbase provides a client to their memcached server, but I'm trying to get the enyim.caching client to work.

这是我使用Couchbase客户端(有效)的简单C#代码,然后使用enyim MemcachedClient进行几乎相同的操作:

Here's my trivial c# code that uses the Couchbase client (which works) and then pretty much the same thing with the enyim MemcachedClient:

class Program
{
    static void Main(string[] args)
    {
        var client = new CouchbaseClient();

        client.Store(StoreMode.Set, "somekey", "somevalue");

        var somevalue = client.Get<string>("somekey");

        Console.WriteLine(somevalue);
        Console.ReadLine();

        var mclient = new MemcachedClient();
        mclient.Store(StoreMode.Set, "Hello", "World");
        var myVal = mclient.Get<string>("Hello");
        Console.WriteLine(myVal);
        Console.ReadLine();
    }
}

这是我的app.config:

Here's my app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
      <section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
      <sectionGroup name="enyim.com">
        <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />      
      </sectionGroup>
    </configSections>
    <couchbase>
      <servers bucket="default" bucketPassword="myPassword">
        <add uri="http://127.0.0.1:8091/pools"/>
      </servers>
    </couchbase>
<enyim.com>
  <memcached>
    <servers>
      <add address="127.0.0.1" port="8091" />
    </servers>
    <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:10:00" deadTimeout="00:02:00" />
    <authentication type="Enyim.Caching.Memcached.PlainTextAuthenticator, Enyim.Caching" zone="" userName="Administrator" password="myPassword" />
  </memcached>
</enyim.com>
<startup>
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>  
</configuration>

当我单步执行代码时,Couchbase客户端似乎可以正常工作. Get方法按预期返回"somevalue".该代码还愉快地执行了MemcachedClient代码,但是当我执行Store方法时,它挂起了10秒钟(我认为是超时),然后myVal值返回为null.没有引发任何错误.

When I step through the code, the Couchbase client appears to work fine. The Get method returns "somevalue" as expected. The code also happily steps through the MemcachedClient code, but when I step through the Store method, it hangs for 10 seconds (I think that's the timeout) and then the myVal value returns as null. No errors are thrown.

我怀疑问题与配置中memcached的身份验证节点中的zone值有关.在enyim.caching源代码(从Github中检索)中的DemoApp代码中,从未指定区域,但是如果未提供区域,则enyim会引发错误-即DemoApp无法按原样工作,因为区域是' t提供.

I suspect the problem revolves around the zone value in the authentication node for memcached in the config. In the DemoApp code that is in the enyim.caching source code (retrieved from Github), zone is never specified, but enyim throws an error if the zone isn't provided - i.e. the DemoApp doesn't work as is because zone isn't provided.

我不确定这是问题所在,但我知道我无法将区域排除在外,但是我不知道该值用什么.我已经看到了使用'AUTHZ'的示例,但这似乎没有什么区别.

I'm not sure this is the problem, but I do know that I can't leave zone out, but I don't know what to use for that value. I've seen an example where 'AUTHZ' was used, but that doesn't seem to make any difference.

有人在这里看到我在做什么错吗?任何帮助表示赞赏! :)

Does anyone see what I'm doing wrong here? Any help is appreciated! :)

推荐答案

好-我知道发生了什么.我回到Couchbase控制台,发现我唯一的数据桶是Couchbase类型的.因此,我创建了一个Memcached类型的新数据桶.我注意到此存储桶类型不需要身份验证.我确实不得不给它一个新的端口.

Ok - I figured out what was going on. I went back into the Couchbase Console and noticed that my only databucket was of type Couchbase. So, I created a new databucket of type Memcached. I noticed that this bucket type required no authentication. I did have to give it a new port.

一旦我对配置文件进行了最小的更改,enyim.caching MemcachedClient代码就可以完美运行!

Once I made the minimal changes to my config file, the enyim.caching MemcachedClient code worked perfectly!

这是我的新enyim.caching配置文件现在的样子:

Here's what my new enyim.caching config stuff looks like now:

<enyim.com>
  <memcached>
    <servers>
      <add address="127.0.0.1" port="8095" />
    </servers>
    <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:10:00" deadTimeout="00:02:00" />
  </memcached>
</enyim.com>

我会尽快将此答案标记为解决方案.希望这可以帮助某人避免犯错. :)

I will mark this answer as the solution as soon as I'm able. Hopefully this may help someone from making my knuckleheaded mistake. :)

更新:

在评论中查看John Zablocki提供的另一种解决方案.谢谢约翰!

Take a look in the comments for another solution provided by John Zablocki. Thanks John!

这篇关于无法使Enyim.Caching MemcachedClient与Couchbase一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆