| 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 dscache | 5 package dscache |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "time" | 8 "time" |
| 9 | 9 |
| 10 ds "github.com/luci/gae/service/datastore" | 10 ds "github.com/luci/gae/service/datastore" |
| 11 "github.com/luci/gae/service/memcache" | 11 "github.com/luci/gae/service/memcache" |
| 12 log "github.com/luci/luci-go/common/logging" | 12 log "github.com/luci/luci-go/common/logging" |
| 13 "golang.org/x/net/context" | 13 "golang.org/x/net/context" |
| 14 ) | 14 ) |
| 15 | 15 |
| 16 type dsCache struct { | 16 type dsCache struct { |
| 17 ds.RawInterface | 17 ds.RawInterface |
| 18 | 18 |
| 19 *supportContext | 19 *supportContext |
| 20 } | 20 } |
| 21 | 21 |
| 22 var _ ds.RawInterface = (*dsCache)(nil) | 22 var _ ds.RawInterface = (*dsCache)(nil) |
| 23 | 23 |
| 24 func (d *dsCache) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { | 24 func (d *dsCache) DeleteMulti(keys []*ds.Key, cb ds.DeleteMultiCB) error { |
| 25 return d.mutation(keys, func() error { | 25 return d.mutation(keys, func() error { |
| 26 return d.RawInterface.DeleteMulti(keys, cb) | 26 return d.RawInterface.DeleteMulti(keys, cb) |
| 27 }) | 27 }) |
| 28 } | 28 } |
| 29 | 29 |
| 30 func (d *dsCache) PutMulti(keys []ds.Key, vals []ds.PropertyMap, cb ds.PutMultiC
B) error { | 30 func (d *dsCache) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMulti
CB) error { |
| 31 return d.mutation(keys, func() error { | 31 return d.mutation(keys, func() error { |
| 32 return d.RawInterface.PutMulti(keys, vals, cb) | 32 return d.RawInterface.PutMulti(keys, vals, cb) |
| 33 }) | 33 }) |
| 34 } | 34 } |
| 35 | 35 |
| 36 func (d *dsCache) GetMulti(keys []ds.Key, metas ds.MultiMetaGetter, cb ds.GetMul
tiCB) error { | 36 func (d *dsCache) GetMulti(keys []*ds.Key, metas ds.MultiMetaGetter, cb ds.GetMu
ltiCB) error { |
| 37 lockItems, nonce := d.mkRandLockItems(keys, metas) | 37 lockItems, nonce := d.mkRandLockItems(keys, metas) |
| 38 if len(lockItems) == 0 { | 38 if len(lockItems) == 0 { |
| 39 return d.RawInterface.GetMulti(keys, metas, cb) | 39 return d.RawInterface.GetMulti(keys, metas, cb) |
| 40 } | 40 } |
| 41 | 41 |
| 42 if err := d.mc.AddMulti(lockItems); err != nil { | 42 if err := d.mc.AddMulti(lockItems); err != nil { |
| 43 (log.Fields{log.ErrorKey: err}).Warningf( | 43 (log.Fields{log.ErrorKey: err}).Warningf( |
| 44 d.c, "dscache: GetMulti: memcache.AddMulti") | 44 d.c, "dscache: GetMulti: memcache.AddMulti") |
| 45 | 45 |
| 46 } | 46 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 if err == nil { | 130 if err == nil { |
| 131 err = txnState.apply(d.supportContext) | 131 err = txnState.apply(d.supportContext) |
| 132 } | 132 } |
| 133 return err | 133 return err |
| 134 }, opts) | 134 }, opts) |
| 135 if err == nil { | 135 if err == nil { |
| 136 txnState.release(d.supportContext) | 136 txnState.release(d.supportContext) |
| 137 } | 137 } |
| 138 return err | 138 return err |
| 139 } | 139 } |
| OLD | NEW |