【问题标题】:Can't store object into membased, how can I know why?无法将对象存储到 membased 中,我怎么知道为什么?
【发布时间】:2012-01-11 22:00:17
【问题描述】:

我正在尝试将对象存储到缓存中,例如:

Dictionary<Guid, Decimal> cacheSubscribers = 
          client.Get<Dictionary<Guid, Decimal>>("ListAllSubscribers");

if (cacheSubscribers == null)
{
  cacheSubscribers = db.JK_Subscribers
                       .Where(x => x.sync)
                       .Select(x => new { x.guid, x.subscriber_id })
                       .ToDictionary(x => x.guid, x => x.subscriber_id);

  if (!client.Store(StoreMode.Set, "ListAllSubscribers", cacheSubscribers, ts))
     MessageBox.Show("Could not store ListAllSubscribers");
}

而且我总是把client.Store 变成false,它不会添加到服务器中。

这句话下面几行我也有:

IEnumerable<JK_ChallengeAnswers> challengeAnswers = client.Get<IEnumerable<JK_ChallengeAnswers>>("ListAllChallengeAnswers");
if (challengeAnswers == null)
{
    challengeAnswers = db.JK_ChallengeAnswers.Include("JK_Challenges").ToList();
    client.Store(StoreMode.Set, "ListAllChallengeAnswers", challengeAnswers, ts);
}

而这总是添加到记忆中...

有没有办法得到我不能存储对象的原因?

Dictionary 有大约 95.000 条记录,在我的配置中

<socketPool minPoolSize="10" 
            maxPoolSize="100" 
            connectionTimeout="00:01:00" 
            deadTimeout="00:02:00" />

附:我在localhost上使用Couchbase

【问题讨论】:

    标签: c# winforms memcached couchbase enyim


    【解决方案1】:

    您可以使用[ExecuteStore][1] 方法,该方法返回IStoreOperationResult 对象而不是bool,您可以在其中找到消息、异常等。
    它并不总是有帮助,但值得一试。

    编辑:为此使用 Couchbase .NET 客户端库 1.1

    【讨论】:

      【解决方案2】:

      我不确定,因为代码不熟悉..所以我问:您是否要存储由 95000 条记录组成的字典? Membase 与 memcached 非常相似,所以我建议检查您可以存储的对象的大小是否有限制。我知道 memcached 是 1mb

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-30
        • 2021-12-08
        • 2020-02-08
        • 1970-01-01
        • 2015-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多