【问题标题】:Is memcache working in go on appengine?memcache 在 appengine 上工作吗?
【发布时间】:2013-11-14 23:24:46
【问题描述】:

我有一个应用程序尝试在 memcache 中存储小图像(小于 50kB),但每次调用 memcache.Set() 都会导致错误 memcache: server error。 我在共享内存缓存类上,所以我知道没有服务保证,但目前我根本没有服务。 是临时停电吗?我是不是运气不好?

这是创建项目并调用 memcache 的一段代码。 ctx 是请求的 appengine 上下文。 memkey 是我的密钥(一个字符串)。 img_data 是我的数据的字符串。 此代码在本地开发环境中运行良好。

cache_item = &memcache.Item{
    Key: memkey,
    Value: bytes.NewBufferString(img_data).Bytes(),
}
err = memcache.Set(ctx, cache_item)
if err != nil {
    ctx.Infof("Could not store image in memcache: %s", err)
}

【问题讨论】:

  • 你能展示你的代码吗?

标签: google-app-engine go memcached


【解决方案1】:

如果仍然存在,请提交错误,但我怀疑这只是暂时性问题。

顺便说一句,您的 Value 初始化程序过于复杂。这将是相同的:

cache_item = &memcache.Item{
    Key:   memkey,
    Value: []byte(img_data),
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-14
    • 2014-06-22
    • 2012-05-07
    • 1970-01-01
    • 2010-12-16
    • 1970-01-01
    • 2021-07-23
    相关资源
    最近更新 更多