| 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" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if len(lockItems) == 0 { | 39 if len(lockItems) == 0 { |
| 40 return d.RawInterface.GetMulti(keys, metas, cb) | 40 return d.RawInterface.GetMulti(keys, metas, cb) |
| 41 } | 41 } |
| 42 | 42 |
| 43 if err := d.mc.AddMulti(lockItems); err != nil { | 43 if err := d.mc.AddMulti(lockItems); err != nil { |
| 44 // 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 |
| 45 // (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 |
| 46 // 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). |
| 47 } | 47 } |
| 48 if err := errors.Filter(d.mc.GetMulti(lockItems), memcache.ErrCacheMiss)
; err != nil { | 48 if err := errors.Filter(d.mc.GetMulti(lockItems), memcache.ErrCacheMiss)
; err != nil { |
| 49 » » (log.Fields{log.ErrorKey: err}).Warningf( | 49 » » (log.Fields{log.ErrorKey: err}).Debugf( |
| 50 d.c, "dscache: GetMulti: memcache.GetMulti") | 50 d.c, "dscache: GetMulti: memcache.GetMulti") |
| 51 } | 51 } |
| 52 | 52 |
| 53 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}) |
| 54 | 54 |
| 55 if !p.empty() { | 55 if !p.empty() { |
| 56 // 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 |
| 57 // to save stuff back to memcache. | 57 // to save stuff back to memcache. |
| 58 | 58 |
| 59 toCas := []memcache.Item{} | 59 toCas := []memcache.Item{} |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 toCas = append(toCas, toSave) | 103 toCas = append(toCas, toSave) |
| 104 } | 104 } |
| 105 return nil | 105 return nil |
| 106 }) | 106 }) |
| 107 if err != nil { | 107 if err != nil { |
| 108 return err | 108 return err |
| 109 } | 109 } |
| 110 if len(toCas) > 0 { | 110 if len(toCas) > 0 { |
| 111 // we have entries to save back to memcache. | 111 // we have entries to save back to memcache. |
| 112 if err := d.mc.CompareAndSwapMulti(toCas); err != nil { | 112 if err := d.mc.CompareAndSwapMulti(toCas); err != nil { |
| 113 » » » » (log.Fields{log.ErrorKey: err}).Warningf( | 113 » » » » (log.Fields{log.ErrorKey: err}).Debugf( |
| 114 d.c, "dscache: GetMulti: memcache.Compar
eAndSwapMulti") | 114 d.c, "dscache: GetMulti: memcache.Compar
eAndSwapMulti") |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 // finally, run the callback for all of the decoded items and the errors
, | 119 // finally, run the callback for all of the decoded items and the errors
, |
| 120 // if any. | 120 // if any. |
| 121 for i, dec := range p.decoded { | 121 for i, dec := range p.decoded { |
| 122 if err := cb(dec, p.lme.GetOne(i)); err != nil { | 122 if err := cb(dec, p.lme.GetOne(i)); err != nil { |
| 123 return err | 123 return err |
| (...skipping 11 matching lines...) Expand all Loading... |
| 135 if err == nil { | 135 if err == nil { |
| 136 err = txnState.apply(d.supportContext) | 136 err = txnState.apply(d.supportContext) |
| 137 } | 137 } |
| 138 return err | 138 return err |
| 139 }, opts) | 139 }, opts) |
| 140 if err == nil { | 140 if err == nil { |
| 141 txnState.release(d.supportContext) | 141 txnState.release(d.supportContext) |
| 142 } | 142 } |
| 143 return err | 143 return err |
| 144 } | 144 } |
| OLD | NEW |