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

Unified Diff: service/memcache/interface.go

Issue 1270063003: Make the rest of the services have a similar raw/user interface structure. (Closed) Base URL: https://github.com/luci/gae.git@add_datastore
Patch Set: address comments Created 5 years, 4 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 | « service/memcache/context.go ('k') | service/memcache/memcache.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/memcache/interface.go
diff --git a/service/memcache/interface.go b/service/memcache/interface.go
index 346155b42e8b2c5fff93b8027a88f811573592cd..0c043b6aac42669e590b0edd446c60742e4e4ae7 100644
--- a/service/memcache/interface.go
+++ b/service/memcache/interface.go
@@ -5,25 +5,67 @@
package memcache
// Interface is the full interface to the memcache service.
+//
+// The *Multi methods may return a "github.com/luci/luci-go/common/errors".MultiError
+// if the rpc to the server was successful, but, e.g. some of the items were
+// missing. They may also return a regular error, if, for example, the rpc
+// failed outright.
type Interface interface {
+ // NewItem creates a new, mutable, memcache item.
NewItem(key string) Item
+ // Add puts a single item into memcache, but only if it didn't exist in
+ // memcache before.
Add(item Item) error
+
+ // Set the item in memcache, whether or not it exists.
Set(item Item) error
- Get(key string) (Item, error)
+
+ // Get retrieves an item from memcache. Only the key field is read. The item
+ // will be mutated to contain the data in the memcache item.
+ Get(item Item) error
+
+ // Delete removes an item from memcache.
Delete(key string) error
+
+ // CompareAndSwap accepts an item which is the result of Get() or GetMulti().
+ // The Get functions add a secret field to item ('CasID'), which is used as
+ // the "compare" value for the "CompareAndSwap". The actual "Value" field of
+ // the object set by the Get functions is the "swap" value.
+ //
+ // Example:
+ // mc := memcache.Get(context)
+ // itm := mc.NewItem("aKey")
+ // mc.Get(itm) // check error
+ // itm.SetValue(append(itm.Value(), []byte("more bytes")))
+ // mc.CompareAndSwap(itm) // check error
CompareAndSwap(item Item) error
AddMulti(items []Item) error
SetMulti(items []Item) error
- GetMulti(keys []string) (map[string]Item, error)
+ GetMulti(items []Item) error
DeleteMulti(keys []string) error
CompareAndSwapMulti(items []Item) error
+ // Increment adds delta to the uint64 contained at key. If the memcache key
+ // is missing, it's populated with initialValue before applying delta (i.e.
+ // the final value would be initialValue+delta).
+ //
+ // Underflow caps at 0, overflow wraps back to 0.
+ //
+ // If key contains a value which is not exactly 8 bytes, it's assumed to
+ // contain non-number data and this method will return an error.
Increment(key string, delta int64, initialValue uint64) (newValue uint64, err error)
+
+ // IncrementExisting is like Increment, except that the valu must exist
+ // already.
IncrementExisting(key string, delta int64) (newValue uint64, err error)
+ // Flush dumps the entire memcache state.
Flush() error
+ // Stats gets some best-effort statistics about the current state of memcache.
Stats() (*Statistics, error)
+
+ Raw() RawInterface
}
« no previous file with comments | « service/memcache/context.go ('k') | service/memcache/memcache.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698