| 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 "github.com/luci/luci-go/common/errors" |
| 12 log "github.com/luci/luci-go/common/logging" | 13 log "github.com/luci/luci-go/common/logging" |
| 13 "golang.org/x/net/context" | 14 "golang.org/x/net/context" |
| 14 ) | 15 ) |
| 15 | 16 |
| 16 type dsCache struct { | 17 type dsCache struct { |
| 17 ds.RawInterface | 18 ds.RawInterface |
| 18 | 19 |
| 19 *supportContext | 20 *supportContext |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 lockItems, nonce := d.mkRandLockItems(keys, metas) | 38 lockItems, nonce := d.mkRandLockItems(keys, metas) |
| 38 if len(lockItems) == 0 { | 39 if len(lockItems) == 0 { |
| 39 return d.RawInterface.GetMulti(keys, metas, cb) | 40 return d.RawInterface.GetMulti(keys, metas, cb) |
| 40 } | 41 } |
| 41 | 42 |
| 42 if err := d.mc.AddMulti(lockItems); err != nil { | 43 if err := d.mc.AddMulti(lockItems); err != nil { |
| 43 // Ignore this error. Either we couldn't add them because they e
xist | 44 // Ignore this error. Either we couldn't add them because they e
xist |
| 44 // (so, not an issue), or because memcache is having sad times (
in which | 45 // (so, not an issue), or because memcache is having sad times (
in which |
| 45 // case we'll see so in the GetMulti which immediately follows t
his). | 46 // case we'll see so in the GetMulti which immediately follows t
his). |
| 46 } | 47 } |
| 47 » if err := d.mc.GetMulti(lockItems); err != nil { | 48 » if err := errors.Filter(d.mc.GetMulti(lockItems), memcache.ErrCacheMiss)
; err != nil { |
| 48 (log.Fields{log.ErrorKey: err}).Warningf( | 49 (log.Fields{log.ErrorKey: err}).Warningf( |
| 49 d.c, "dscache: GetMulti: memcache.GetMulti") | 50 d.c, "dscache: GetMulti: memcache.GetMulti") |
| 50 } | 51 } |
| 51 | 52 |
| 52 p := makeFetchPlan(d.c, d.aid, d.ns, &facts{keys, metas, lockItems, nonc
e}) | 53 p := makeFetchPlan(d.c, d.aid, d.ns, &facts{keys, metas, lockItems, nonc
e}) |
| 53 | 54 |
| 54 if !p.empty() { | 55 if !p.empty() { |
| 55 // looks like we have something to pull from datastore, and mayb
e some work | 56 // looks like we have something to pull from datastore, and mayb
e some work |
| 56 // to save stuff back to memcache. | 57 // to save stuff back to memcache. |
| 57 | 58 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if err == nil { | 133 if err == nil { |
| 133 err = txnState.apply(d.supportContext) | 134 err = txnState.apply(d.supportContext) |
| 134 } | 135 } |
| 135 return err | 136 return err |
| 136 }, opts) | 137 }, opts) |
| 137 if err == nil { | 138 if err == nil { |
| 138 txnState.release(d.supportContext) | 139 txnState.release(d.supportContext) |
| 139 } | 140 } |
| 140 return err | 141 return err |
| 141 } | 142 } |
| OLD | NEW |