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

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

Issue 1355783002: Refactor keys and queries in datastore service and implementation. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: appease errcheck Created 5 years, 3 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
« no previous file with comments | « impl/memory/gkvlite_utils.go ('k') | impl/memory/memcache_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 201
202 func (m *memcacheImpl) AddMulti(items []mc.Item, cb mc.RawCB) error { 202 func (m *memcacheImpl) AddMulti(items []mc.Item, cb mc.RawCB) error {
203 now := clock.Now(m.ctx) 203 now := clock.Now(m.ctx)
204 doCBs(items, cb, func(itm mc.Item) error { 204 doCBs(items, cb, func(itm mc.Item) error {
205 m.data.lock.Lock() 205 m.data.lock.Lock()
206 defer m.data.lock.Unlock() 206 defer m.data.lock.Unlock()
207 if !m.data.hasItemLocked(now, itm.Key()) { 207 if !m.data.hasItemLocked(now, itm.Key()) {
208 m.data.setItemLocked(now, itm) 208 m.data.setItemLocked(now, itm)
209 return nil 209 return nil
210 } else {
211 return mc.ErrNotStored
212 } 210 }
211 return mc.ErrNotStored
213 }) 212 })
214 return nil 213 return nil
215 } 214 }
216 215
217 func (m *memcacheImpl) CompareAndSwapMulti(items []mc.Item, cb mc.RawCB) error { 216 func (m *memcacheImpl) CompareAndSwapMulti(items []mc.Item, cb mc.RawCB) error {
218 now := clock.Now(m.ctx) 217 now := clock.Now(m.ctx)
219 doCBs(items, cb, func(itm mc.Item) error { 218 doCBs(items, cb, func(itm mc.Item) error {
220 m.data.lock.Lock() 219 m.data.lock.Lock()
221 defer m.data.lock.Unlock() 220 defer m.data.lock.Unlock()
222 221
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 return cur, nil 342 return cur, nil
344 } 343 }
345 344
346 func (m *memcacheImpl) Stats() (*mc.Statistics, error) { 345 func (m *memcacheImpl) Stats() (*mc.Statistics, error) {
347 m.data.lock.RLock() 346 m.data.lock.RLock()
348 defer m.data.lock.RUnlock() 347 defer m.data.lock.RUnlock()
349 348
350 ret := m.data.stats 349 ret := m.data.stats
351 return &ret, nil 350 return &ret, nil
352 } 351 }
OLDNEW
« no previous file with comments | « impl/memory/gkvlite_utils.go ('k') | impl/memory/memcache_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698