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

Side by Side Diff: go/src/infra/gae/libs/wrapper/memory/memcache.go

Issue 1143053004: Simplify memory package interface. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: switch to blasters Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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 memory 5 package memory
6 6
7 import ( 7 import (
8 "infra/gae/libs/wrapper" 8 "infra/gae/libs/wrapper"
9 "infra/gae/libs/wrapper/gae/commonErrors" 9 "infra/gae/libs/wrapper/gae/commonErrors"
10 "infra/gae/libs/wrapper/unsafe" 10 "infra/gae/libs/wrapper/unsafe"
(...skipping 21 matching lines...) Expand all
32 32
33 data *memcacheData 33 data *memcacheData
34 timeNow func() time.Time 34 timeNow func() time.Time
35 } 35 }
36 36
37 var ( 37 var (
38 _ = wrapper.Memcache((*memcacheImpl)(nil)) 38 _ = wrapper.Memcache((*memcacheImpl)(nil))
39 _ = wrapper.Testable((*memcacheImpl)(nil)) 39 _ = wrapper.Testable((*memcacheImpl)(nil))
40 ) 40 )
41 41
42 // UseMC adds a wrapper.Memcache implementation to context, accessible 42 // useMC adds a wrapper.Memcache implementation to context, accessible
43 // by wrapper.GetMC(c) 43 // by wrapper.GetMC(c)
44 func UseMC(c context.Context) context.Context { 44 func useMC(c context.Context) context.Context {
45 lck := sync.Mutex{} 45 lck := sync.Mutex{}
46 mcdMap := map[string]*memcacheData{} 46 mcdMap := map[string]*memcacheData{}
47 47
48 return wrapper.SetMCFactory(c, func(ic context.Context) wrapper.Memcache { 48 return wrapper.SetMCFactory(c, func(ic context.Context) wrapper.Memcache {
49 lck.Lock() 49 lck.Lock()
50 defer lck.Unlock() 50 defer lck.Unlock()
51 51
52 ns := curGID(ic).namespace 52 ns := curGID(ic).namespace
53 mcd, ok := mcdMap[ns] 53 mcd, ok := mcdMap[ns]
54 if !ok { 54 if !ok {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 m.data.lock.Lock() 178 m.data.lock.Lock()
179 defer m.data.lock.Unlock() 179 defer m.data.lock.Unlock()
180 180
181 if _, ok := m.retrieve(key); ok { 181 if _, ok := m.retrieve(key); ok {
182 delete(m.data.items, key) 182 delete(m.data.items, key)
183 return nil 183 return nil
184 } 184 }
185 return memcache.ErrCacheMiss 185 return memcache.ErrCacheMiss
186 } 186 }
OLDNEW
« no previous file with comments | « go/src/infra/gae/libs/wrapper/memory/key_test.go ('k') | go/src/infra/gae/libs/wrapper/memory/memcache_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698