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

Side by Side 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: 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 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 memcache 5 package memcache
6 6
7 // Interface is the full interface to the memcache service. 7 // Interface is the full interface to the memcache service.
dnj 2015/08/03 22:37:25 Document when MultiError instances will be returne
iannucci 2015/08/04 01:21:21 Done.
8 type Interface interface { 8 type Interface interface {
9 // NewItem creates a new, mutable, memcache item.
9 NewItem(key string) Item 10 NewItem(key string) Item
10 11
12 // Add puts a single item into memcache, but only if it didn't exist in
13 // memcache before.
11 Add(item Item) error 14 Add(item Item) error
15
16 // Set the item in memcache, whether or not it exists.
12 Set(item Item) error 17 Set(item Item) error
13 » Get(key string) (Item, error) 18
19 » // Get retrieves an item from memcache. Only the key field is read. The item
20 » // will be mutated to contain the data in the memcache item.
21 » Get(item Item) error
22
23 » // Delete removes an item from memcache.
14 Delete(key string) error 24 Delete(key string) error
25
26 // CompareAndSwap accepts an item which is the result of Get() or GetMul ti().
27 // The Get functions add a secret field to item ('CasID'), which is used as
28 // the "compare" value for the "CompareAndSwap". The actual "Value" fiel d of
29 // the object set by the Get functions is the "swap" value.
30 //
31 // Example:
32 // mc := memcache.Get(context)
33 // itm := mc.NewItem("aKey")
34 // mc.Get(itm) // check error
35 // itm.SetValue(append(itm.Value(), []byte("more bytes")))
36 // mc.CompareAndSwap(itm) // check error
15 CompareAndSwap(item Item) error 37 CompareAndSwap(item Item) error
16 38
17 AddMulti(items []Item) error 39 AddMulti(items []Item) error
dnj 2015/08/03 22:37:25 Exported methods need comments.
iannucci 2015/08/04 01:21:21 Not on an interface, and if the reader can't figur
dnj (Google) 2015/08/04 03:48:03 http://fxr.watson.org/fxr/ident?im=3;i=EDOOFUS
18 SetMulti(items []Item) error 40 SetMulti(items []Item) error
19 » GetMulti(keys []string) (map[string]Item, error) 41 » GetMulti(items []Item) error
20 DeleteMulti(keys []string) error 42 DeleteMulti(keys []string) error
21 CompareAndSwapMulti(items []Item) error 43 CompareAndSwapMulti(items []Item) error
22 44
45 // Increment adds delta to the uint64 contained at key. If the memcache key
46 // is missing, it's populated with initialValue before applying delta (i .e.
47 // the final value would be initialValue+delta).
48 //
49 // Underflow caps at 0, overflow wraps back to 0.
50 //
51 // If key contains a value which is not exactly 8 bytes, it's assumed to
52 // contain non-number data and this method will return an error.
23 Increment(key string, delta int64, initialValue uint64) (newValue uint64 , err error) 53 Increment(key string, delta int64, initialValue uint64) (newValue uint64 , err error)
54
55 // IncrementExisting is like Increment, except that the valu must exist
56 // already.
24 IncrementExisting(key string, delta int64) (newValue uint64, err error) 57 IncrementExisting(key string, delta int64) (newValue uint64, err error)
25 58
59 // Flush dumps the entire memcache state.
26 Flush() error 60 Flush() error
27 61
62 // Stats gets some best-effort statistics about the current state of mem cache.
28 Stats() (*Statistics, error) 63 Stats() (*Statistics, error)
64
65 Raw() RawInterface
29 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698