groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.
Перейти к файлу
Joe Tsai 41bb18bfe9
add back Context type as alias to context.Context (#148)
Pull request #131 deleted the Context declaration,
which broke most usages of this package since users needed to implement
the interfaces mentioned in this package by referencing the
groupcache.Context type. However, that type was removed from peers.go
in the mentioned pull request.

Technically, #131 is a breaking change since groupcache.Context
was an interface{}, and the PR switched it to be context.Context.
Fortunately, it seems that all users are passing a context.Context
anyways so that the type safety just checks out.

However, most users are still referencing groupcache.Context.
2021-03-31 18:47:55 -04:00
consistenthash Fix function comments based on best practices from Effective Go 2019-10-25 08:05:17 -07:00
groupcachepb groupcachepb: add syntax declaration to proto file 2016-02-11 14:40:41 -08:00
lru lru: fix misspelling (#112) 2019-01-29 07:46:38 -08:00
singleflight format error string as per go style (#127) 2019-10-27 14:21:12 -07:00
testpb testpb: add syntax declaration to proto file 2016-02-11 14:59:07 -08:00
.gitignore initial commit. 2013-07-23 18:03:06 -07:00
.travis.yml Bump Travis versions 2018-10-20 01:13:27 +02:00
LICENSE initial commit. 2013-07-23 18:03:06 -07:00
README.md Make it clearer that groupcache is distributed 2019-10-02 13:19:03 -07:00
byteview.go Implement WriterTo 2017-03-02 14:33:40 -08:00
byteview_test.go Implement WriterTo 2017-03-02 14:33:40 -08:00
groupcache.go use std library context.Context (#131) 2019-12-26 21:28:52 -08:00
groupcache_test.go use std library context.Context (#131) 2019-12-26 21:28:52 -08:00
http.go http: make http client request with context (#132) 2020-01-20 23:51:36 -05:00
http_test.go http: make http client request with context (#132) 2020-01-20 23:51:36 -05:00
peers.go add back Context type as alias to context.Context (#148) 2021-03-31 18:47:55 -04:00
sinks.go correct spelling mistake 2017-09-01 12:37:39 +01:00

README.md

groupcache

Summary

groupcache is a distributed caching and cache-filling library, intended as a replacement for a pool of memcached nodes in many cases.

For API docs and examples, see http://godoc.org/github.com/golang/groupcache

Comparison to memcached

Like memcached, groupcache:

  • shards by key to select which peer is responsible for that key

Unlike memcached, groupcache:

  • does not require running a separate set of servers, thus massively reducing deployment/configuration pain. groupcache is a client library as well as a server. It connects to its own peers, forming a distributed cache.

  • comes with a cache filling mechanism. Whereas memcached just says "Sorry, cache miss", often resulting in a thundering herd of database (or whatever) loads from an unbounded number of clients (which has resulted in several fun outages), groupcache coordinates cache fills such that only one load in one process of an entire replicated set of processes populates the cache, then multiplexes the loaded value to all callers.

  • does not support versioned values. If key "foo" is value "bar", key "foo" must always be "bar". There are neither cache expiration times, nor explicit cache evictions. Thus there is also no CAS, nor Increment/Decrement. This also means that groupcache....

  • ... supports automatic mirroring of super-hot items to multiple processes. This prevents memcached hot spotting where a machine's CPU and/or NIC are overloaded by very popular keys/values.

  • is currently only available for Go. It's very unlikely that I (bradfitz@) will port the code to any other language.

Loading process

In a nutshell, a groupcache lookup of Get("foo") looks like:

(On machine #5 of a set of N machines running the same code)

  1. Is the value of "foo" in local memory because it's super hot? If so, use it.

  2. Is the value of "foo" in local memory because peer #5 (the current peer) is the owner of it? If so, use it.

  3. Amongst all the peers in my set of N, am I the owner of the key "foo"? (e.g. does it consistent hash to 5?) If so, load it. If other callers come in, via the same process or via RPC requests from peers, they block waiting for the load to finish and get the same answer. If not, RPC to the peer that's the owner and get the answer. If the RPC fails, just load it locally (still with local dup suppression).

Users

groupcache is in production use by dl.google.com (its original user), parts of Blogger, parts of Google Code, parts of Google Fiber, parts of Google production monitoring systems, etc.

Presentations

See http://talks.golang.org/2013/oscon-dl.slide

Help

Use the golang-nuts mailing list for any discussion or questions.