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

Unified Diff: go/src/infra/gae/libs/wrapper/gae/memcache.go

Issue 1230303003: Revert "Refactor current GAE abstraction library to be free of the SDK*" (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 5 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 | « go/src/infra/gae/libs/wrapper/gae/globalinfo.go ('k') | go/src/infra/gae/libs/wrapper/gae/taskqueue.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/wrapper/gae/memcache.go
diff --git a/go/src/infra/gae/libs/wrapper/gae/memcache.go b/go/src/infra/gae/libs/wrapper/gae/memcache.go
new file mode 100644
index 0000000000000000000000000000000000000000..1d1fdb926e208d03720e6bddb1e553dfd624402c
--- /dev/null
+++ b/go/src/infra/gae/libs/wrapper/gae/memcache.go
@@ -0,0 +1,111 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package gae
+
+import (
+ "golang.org/x/net/context"
+
+ "appengine"
+ "appengine/memcache"
+
+ "infra/gae/libs/wrapper"
+)
+
+// useMC adds a wrapper.Memcache implementation to context, accessible
+// by wrapper.GetMC(c)
+func useMC(c context.Context) context.Context {
+ return wrapper.SetMCFactory(c, func(ci context.Context) wrapper.Memcache {
+ return mcImpl{ctx(c).Context}
+ })
+}
+
+type mcImpl struct {
+ appengine.Context
+}
+
+//////// MCSingleReadWriter
+func (m mcImpl) Add(item *memcache.Item) error {
+ return memcache.Add(m.Context, item)
+}
+func (m mcImpl) Set(item *memcache.Item) error {
+ return memcache.Set(m.Context, item)
+}
+func (m mcImpl) Delete(key string) error {
+ return memcache.Delete(m.Context, key)
+}
+func (m mcImpl) Get(key string) (*memcache.Item, error) {
+ return memcache.Get(m.Context, key)
+}
+func (m mcImpl) CompareAndSwap(item *memcache.Item) error {
+ return memcache.CompareAndSwap(m.Context, item)
+}
+
+//////// MCMultiReadWriter
+func (m mcImpl) DeleteMulti(keys []string) error {
+ return memcache.DeleteMulti(m.Context, keys)
+}
+func (m mcImpl) AddMulti(items []*memcache.Item) error {
+ return memcache.AddMulti(m.Context, items)
+}
+func (m mcImpl) SetMulti(items []*memcache.Item) error {
+ return memcache.SetMulti(m.Context, items)
+}
+func (m mcImpl) GetMulti(keys []string) (map[string]*memcache.Item, error) {
+ return memcache.GetMulti(m.Context, keys)
+}
+func (m mcImpl) CompareAndSwapMulti(items []*memcache.Item) error {
+ return memcache.CompareAndSwapMulti(m.Context, items)
+}
+
+//////// MCIncrementer
+func (m mcImpl) Increment(key string, delta int64, initialValue uint64) (uint64, error) {
+ return memcache.Increment(m.Context, key, delta, initialValue)
+}
+func (m mcImpl) IncrementExisting(key string, delta int64) (uint64, error) {
+ return memcache.IncrementExisting(m.Context, key, delta)
+}
+
+//////// MCFlusher
+func (m mcImpl) Flush() error {
+ return memcache.Flush(m.Context)
+}
+
+//////// MCStatter
+func (m mcImpl) Stats() (*memcache.Statistics, error) {
+ return memcache.Stats(m.Context)
+}
+
+//////// MCCodecInflater
+type mcCodecCombiner struct {
+ appengine.Context
+ codec memcache.Codec
+}
+
+//////// MCCodecInflater.logger
+func (cc mcCodecCombiner) Set(item *memcache.Item) error {
+ return cc.codec.Set(cc.Context, item)
+}
+func (cc mcCodecCombiner) Add(item *memcache.Item) error {
+ return cc.codec.Add(cc.Context, item)
+}
+func (cc mcCodecCombiner) Get(key string, v interface{}) (*memcache.Item, error) {
+ return cc.codec.Get(cc.Context, key, v)
+}
+func (cc mcCodecCombiner) SetMulti(items []*memcache.Item) error {
+ return cc.codec.SetMulti(cc.Context, items)
+}
+func (cc mcCodecCombiner) AddMulti(items []*memcache.Item) error {
+ return cc.codec.AddMulti(cc.Context, items)
+}
+func (cc mcCodecCombiner) CompareAndSwap(item *memcache.Item) error {
+ return cc.codec.CompareAndSwap(cc.Context, item)
+}
+func (cc mcCodecCombiner) CompareAndSwapMulti(items []*memcache.Item) error {
+ return cc.codec.CompareAndSwapMulti(cc.Context, items)
+}
+
+func (m mcImpl) InflateCodec(codec memcache.Codec) wrapper.MCCodec {
+ return mcCodecCombiner{m.Context, codec}
+}
« no previous file with comments | « go/src/infra/gae/libs/wrapper/gae/globalinfo.go ('k') | go/src/infra/gae/libs/wrapper/gae/taskqueue.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698