5 groupcache is a caching and cache-filling library, intended as a
6 replacement for memcached in many cases.
8 For API docs and examples, see http://godoc.org/github.com/golang/groupcache
10 ## Comparison to memcached
12 ### **Like memcached**, groupcache:
14 * shards by key to select which peer is responsible for that key
16 ### **Unlike memcached**, groupcache:
18 * does not require running a separate set of servers, thus massively
19 reducing deployment/configuration pain. groupcache is a client
20 library as well as a server. It connects to its own peers.
22 * comes with a cache filling mechanism. Whereas memcached just says
23 "Sorry, cache miss", often resulting in a thundering herd of
24 database (or whatever) loads from an unbounded number of clients
25 (which has resulted in several fun outages), groupcache coordinates
26 cache fills such that only one load in one process of an entire
27 replicated set of processes populates the cache, then multiplexes
28 the loaded value to all callers.
30 * does not support versioned values. If key "foo" is value "bar",
31 key "foo" must always be "bar". There are neither cache expiration
32 times, nor explicit cache evictions. Thus there is also no CAS,
33 nor Increment/Decrement. This also means that groupcache....
35 * ... supports automatic mirroring of super-hot items to multiple
36 processes. This prevents memcached hot spotting where a machine's
37 CPU and/or NIC are overloaded by very popular keys/values.
39 * is currently only available for Go. It's very unlikely that I
40 (bradfitz@) will port the code to any other language.
44 In a nutshell, a groupcache lookup of **Get("foo")** looks like:
46 (On machine #5 of a set of N machines running the same code)
48 1. Is the value of "foo" in local memory because it's super hot? If so, use it.
50 2. Is the value of "foo" in local memory because peer #5 (the current
51 peer) is the owner of it? If so, use it.
53 3. Amongst all the peers in my set of N, am I the owner of the key
54 "foo"? (e.g. does it consistent hash to 5?) If so, load it. If
55 other callers come in, via the same process or via RPC requests
56 from peers, they block waiting for the load to finish and get the
57 same answer. If not, RPC to the peer that's the owner and get
58 the answer. If the RPC fails, just load it locally (still with
59 local dup suppression).
63 groupcache is in production use by dl.google.com (its original user),
64 parts of Blogger, parts of Google Code, parts of Google Fiber, parts
65 of Google production monitoring systems, etc.
69 See http://talks.golang.org/2013/oscon-dl.slide
73 Use the golang-nuts mailing list for any discussion or questions.