Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: impl/prod/memcache.go

Issue 1541183002: Make setting a Memcache Item with a nil Value OK (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/prod/everything_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/prod/memcache.go
diff --git a/impl/prod/memcache.go b/impl/prod/memcache.go
index 571eec8beb31bf95361c0985f6b4f4a1392f164b..d75d4bb7df788a48a0764f45808585ade2c9a99b 100644
--- a/impl/prod/memcache.go
+++ b/impl/prod/memcache.go
@@ -74,8 +74,15 @@ func mcR2FErr(i *memcache.Item, err error) (mc.Item, error) {
// mcF2R (MC fake-to-real) converts a mc.Item. i must originate from inside
// this package for this function to work (see the panic message for why).
+//
+// If the item's Value == nil, it will be copied and replaced with []byte{}.
func mcF2R(i mc.Item) *memcache.Item {
if mci, ok := i.(mcItem); ok {
+ if mci.i.Value == nil {
+ ret := *mci.i
+ ret.Value = []byte{}
+ return &ret
+ }
return mci.i
}
panic(
« no previous file with comments | « impl/prod/everything_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698