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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 func (i mcItem) SetFlags(f uint32) mc.Item { | 45 func (i mcItem) SetFlags(f uint32) mc.Item { |
46 i.i.Flags = f | 46 i.i.Flags = f |
47 return i | 47 return i |
48 } | 48 } |
49 func (i mcItem) SetExpiration(d time.Duration) mc.Item { | 49 func (i mcItem) SetExpiration(d time.Duration) mc.Item { |
50 i.i.Expiration = d | 50 i.i.Expiration = d |
51 return i | 51 return i |
52 } | 52 } |
53 | 53 |
54 func (i mcItem) SetAll(other mc.Item) { | 54 func (i mcItem) SetAll(other mc.Item) { |
55 » o := other.(mcItem) | 55 » if other == nil { |
56 » *i.i = *o.i | 56 » » i.i = &memcache.Item{Key: i.i.Key} |
57 » val := i.i.Value | 57 » } else { |
58 » i.i.Value = make([]byte, len(val)) | 58 » » k := i.i.Key |
59 » copy(i.i.Value, val) | 59 » » *i.i = *other.(mcItem).i |
| 60 » » i.i.Key = k |
| 61 » } |
60 } | 62 } |
61 | 63 |
62 // mcR2FErr (MC real-to-fake w/ error) converts a *memcache.Item to a mc.Item, | 64 // mcR2FErr (MC real-to-fake w/ error) converts a *memcache.Item to a mc.Item, |
63 // and passes along an error. | 65 // and passes along an error. |
64 func mcR2FErr(i *memcache.Item, err error) (mc.Item, error) { | 66 func mcR2FErr(i *memcache.Item, err error) (mc.Item, error) { |
65 if err != nil { | 67 if err != nil { |
66 return nil, err | 68 return nil, err |
67 } | 69 } |
68 return mcItem{i}, nil | 70 return mcItem{i}, nil |
69 } | 71 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 return memcache.Flush(m.Context) | 150 return memcache.Flush(m.Context) |
149 } | 151 } |
150 | 152 |
151 func (m mcImpl) Stats() (*mc.Statistics, error) { | 153 func (m mcImpl) Stats() (*mc.Statistics, error) { |
152 stats, err := memcache.Stats(m.Context) | 154 stats, err := memcache.Stats(m.Context) |
153 if err != nil { | 155 if err != nil { |
154 return nil, err | 156 return nil, err |
155 } | 157 } |
156 return (*mc.Statistics)(stats), nil | 158 return (*mc.Statistics)(stats), nil |
157 } | 159 } |
OLD | NEW |