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

Side by Side Diff: impl/memory/memcache.go

Issue 1916463004: impl/memory: Disallow empty namespace. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Remove memcache. Created 4 years, 8 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 "encoding/binary" 8 "encoding/binary"
9 "sync" 9 "sync"
10 "time" 10 "time"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 func useMC(c context.Context) context.Context { 158 func useMC(c context.Context) context.Context {
159 lck := sync.Mutex{} 159 lck := sync.Mutex{}
160 // TODO(riannucci): just use namespace for automatic key prefixing. Flus h 160 // TODO(riannucci): just use namespace for automatic key prefixing. Flus h
161 // actually wipes the ENTIRE memcache, regardless of namespace. 161 // actually wipes the ENTIRE memcache, regardless of namespace.
162 mcdMap := map[string]*memcacheData{} 162 mcdMap := map[string]*memcacheData{}
163 163
164 return mc.SetRawFactory(c, func(ic context.Context) mc.RawInterface { 164 return mc.SetRawFactory(c, func(ic context.Context) mc.RawInterface {
165 lck.Lock() 165 lck.Lock()
166 defer lck.Unlock() 166 defer lck.Unlock()
167 167
168 » » ns := curGID(ic).namespace 168 » » ns, _ := curGID(ic).getNamespace()
169 mcd, ok := mcdMap[ns] 169 mcd, ok := mcdMap[ns]
170 if !ok { 170 if !ok {
171 mcd = &memcacheData{items: map[string]*mcDataItem{}} 171 mcd = &memcacheData{items: map[string]*mcDataItem{}}
172 mcdMap[ns] = mcd 172 mcdMap[ns] = mcd
173 } 173 }
174 174
175 return &memcacheImpl{ 175 return &memcacheImpl{
176 mcd, 176 mcd,
177 ic, 177 ic,
178 } 178 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 return cur, nil 342 return cur, nil
343 } 343 }
344 344
345 func (m *memcacheImpl) Stats() (*mc.Statistics, error) { 345 func (m *memcacheImpl) Stats() (*mc.Statistics, error) {
346 m.data.lock.RLock() 346 m.data.lock.RLock()
347 defer m.data.lock.RUnlock() 347 defer m.data.lock.RUnlock()
348 348
349 ret := m.data.stats 349 ret := m.data.stats
350 return &ret, nil 350 return &ret, nil
351 } 351 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698