Clone of golang/groupcache with TTL and Item Removal support
Go to file
Derrick J. Wippler 054f2178b4 Client keep-alives and hotcache changes
* Now Associating the transport with peer `httpGetter` so we take advantage of
  connection reuse.  This lowers the impact on DNS and improves preformance for
  high request volume low latency applications.
* Now always populating the hotcache. A more complex algorithm is unnecessary
  when the LRU cache will ensure the most used values remain in the cache. The
  evict code ensures the hotcache does not over crowd the maincache.
2019-06-03 10:20:40 -05:00
consistenthash changed default number of replicas in http pool hash ring to 50, and fixed hash ring benchmark 2014-07-08 12:15:05 +03:00
groupcachepb Sinks can not accept an expire time 2019-04-09 17:36:03 -05:00
lru Sinks can not accept an expire time 2019-04-09 17:36:03 -05:00
singleflight Added support for key removal within a group 2019-04-11 10:50:29 -05:00
testpb testpb: add syntax declaration to proto file 2016-02-11 14:59:07 -08:00
.gitignore Added support for go modules 2019-04-09 17:36:47 -05:00
.travis.yml Client keep-alives and hotcache changes 2019-06-03 10:20:40 -05:00
byteview_test.go Implement WriterTo 2017-03-02 14:33:40 -08:00
byteview.go Sinks can not accept an expire time 2019-04-09 17:36:03 -05:00
CHANGELOG Client keep-alives and hotcache changes 2019-06-03 10:20:40 -05:00
go.mod Update go.mod 2019-04-10 15:05:45 -05:00
go.sum Added support for go modules 2019-04-09 17:36:47 -05:00
groupcache_test.go Client keep-alives and hotcache changes 2019-06-03 10:20:40 -05:00
groupcache.go Client keep-alives and hotcache changes 2019-06-03 10:20:40 -05:00
http_test.go Added a CHANGELOG file 2019-05-30 17:24:49 -05:00
http.go Client keep-alives and hotcache changes 2019-06-03 10:20:40 -05:00
LICENSE initial commit. 2013-07-23 18:03:06 -07:00
peers.go Now using context.Context instead of groupcache.Context 2019-05-30 17:03:06 -05:00
proto.sh Added support for go modules 2019-04-09 17:36:47 -05:00
README.md Changed import path to mailgun/groupcache 2019-04-10 15:09:20 -05:00
sinks.go Sinks can not accept an expire time 2019-04-09 17:36:03 -05:00

groupcache

Summary

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

For API docs and examples, see http://godoc.org/github.com/mailgun/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.

  • 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.