I have an app that tries to store small images (less than 50kB) in memcache, but each call to memcache.Set() results in an error memcache: server error
. I'm on the shared memcache class, so I understand there is no service guarantee, but currently I have no service at all. Is it a temporary outage? Am I just unlucky?
Here is the piece of code creating an item and calling memcache. ctx
is the appengine context for the request. memkey
is my key (a string). img_data
is a string with my data. This code works well in the local dev environment.
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)
}
If it's still happening, file a bug, but I suspect it was just a transient problem.
Incidentally, your Value initialiser is unnecessarily complex. This would work the same:
cache_item = &memcache.Item{
Key: memkey,
Value: []byte(img_data),
}