Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: impl/memory/memcache.go

Issue 1269113005: A transparent cache for datastore, backed by memcache. (Closed) Base URL: https://github.com/luci/gae.git@add_meta
Patch Set: fix comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « filter/dscache/support.go ('k') | impl/memory/raw_datastore_data.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/memcache.go
diff --git a/impl/memory/memcache.go b/impl/memory/memcache.go
index 4a38c026a0fc3a06d9859e2d431f86fb8c5fea09..3e1c4b8630f8398052cf82c7e1c93151c1bbfaef 100644
--- a/impl/memory/memcache.go
+++ b/impl/memory/memcache.go
@@ -50,7 +50,13 @@ func (m *mcItem) SetExpiration(exp time.Duration) mc.Item {
}
func (m *mcItem) SetAll(other mc.Item) {
- *m = *other.(*mcItem)
+ if other == nil {
+ *m = mcItem{key: m.key}
+ } else {
+ k := m.key
+ *m = *other.(*mcItem)
+ m.key = k
+ }
}
type mcDataItem struct {
@@ -151,6 +157,8 @@ var _ mc.RawInterface = (*memcacheImpl)(nil)
// by gae.GetMC(c)
func useMC(c context.Context) context.Context {
lck := sync.Mutex{}
+ // TODO(riannucci): just use namespace for automatic key prefixing. Flush
+ // actually wipes the ENTIRE memcache, regardless of namespace.
mcdMap := map[string]*memcacheData{}
return mc.SetRawFactory(c, func(ic context.Context) mc.RawInterface {
@@ -200,7 +208,7 @@ func (m *memcacheImpl) AddMulti(items []mc.Item, cb mc.RawCB) error {
m.data.setItemLocked(now, itm)
return nil
} else {
- return (mc.ErrNotStored)
+ return mc.ErrNotStored
}
})
return nil
« no previous file with comments | « filter/dscache/support.go ('k') | impl/memory/raw_datastore_data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698