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 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 Loading... |
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 Loading... |
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 } |
OLD | NEW |