| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package prod | 5 package prod |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "time" | 8 "time" |
| 9 | 9 |
| 10 mc "github.com/luci/gae/service/memcache" | 10 mc "github.com/luci/gae/service/memcache" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // and passes along an error. | 67 // and passes along an error. |
| 68 func mcR2FErr(i *memcache.Item, err error) (mc.Item, error) { | 68 func mcR2FErr(i *memcache.Item, err error) (mc.Item, error) { |
| 69 if err != nil { | 69 if err != nil { |
| 70 return nil, err | 70 return nil, err |
| 71 } | 71 } |
| 72 return mcItem{i}, nil | 72 return mcItem{i}, nil |
| 73 } | 73 } |
| 74 | 74 |
| 75 // mcF2R (MC fake-to-real) converts a mc.Item. i must originate from inside | 75 // mcF2R (MC fake-to-real) converts a mc.Item. i must originate from inside |
| 76 // this package for this function to work (see the panic message for why). | 76 // this package for this function to work (see the panic message for why). |
| 77 // |
| 78 // If the item's Value == nil, it will be copied and replaced with []byte{}. |
| 77 func mcF2R(i mc.Item) *memcache.Item { | 79 func mcF2R(i mc.Item) *memcache.Item { |
| 78 if mci, ok := i.(mcItem); ok { | 80 if mci, ok := i.(mcItem); ok { |
| 81 if mci.i.Value == nil { |
| 82 ret := *mci.i |
| 83 ret.Value = []byte{} |
| 84 return &ret |
| 85 } |
| 79 return mci.i | 86 return mci.i |
| 80 } | 87 } |
| 81 panic( | 88 panic( |
| 82 "you may not use other mc.Item implementations with this " + | 89 "you may not use other mc.Item implementations with this " + |
| 83 "implementation of gae.Memcache, since it will cause all
CompareAndSwap " + | 90 "implementation of gae.Memcache, since it will cause all
CompareAndSwap " + |
| 84 "operations to fail. Please use the NewItem api instead.
") | 91 "operations to fail. Please use the NewItem api instead.
") |
| 85 } | 92 } |
| 86 | 93 |
| 87 // mcMF2R (MC multi-fake-to-real) converts a slice of mc.Item to a slice of | 94 // mcMF2R (MC multi-fake-to-real) converts a slice of mc.Item to a slice of |
| 88 // *memcache.Item. | 95 // *memcache.Item. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return memcache.Flush(m.aeCtx) | 158 return memcache.Flush(m.aeCtx) |
| 152 } | 159 } |
| 153 | 160 |
| 154 func (m mcImpl) Stats() (*mc.Statistics, error) { | 161 func (m mcImpl) Stats() (*mc.Statistics, error) { |
| 155 stats, err := memcache.Stats(m.aeCtx) | 162 stats, err := memcache.Stats(m.aeCtx) |
| 156 if err != nil { | 163 if err != nil { |
| 157 return nil, err | 164 return nil, err |
| 158 } | 165 } |
| 159 return (*mc.Statistics)(stats), nil | 166 return (*mc.Statistics)(stats), nil |
| 160 } | 167 } |
| OLD | NEW |