What to say next
Start talking about groupcache! today.
Memcached everyone should be not unfamiliar, the official website of the introduction is:
Free & Open Source, high-performance, distributedMemory Object caching System (freeware, open-source, high-performance distributed cache object caching systems). A lot of company's products are used memcached, but memcached is developed in C language, our aim is to improve golang skills, so here I find Golang version of the Memcached:groupcache to analyze.
GitHub Address: Https://github.com/golang/groupcache
Groupcahe is introduced on GitHub:gRoupcache is a caching and cache-filling library, intended as a replacement for MEMCAC Hed in many cases. That is, this is a library, and the goal is to replace the memcached in many scenarios. After reading the source, we turn to see what excellent features of Groupcache, compared to the official introduction of a bunch of features introduced.
Project Overview
Project Source structure:
I see not too intuitive, consistenthash is a consistent hash, GROUPCACHEPB should be and protocol buffers has a relationship, LRU is the least recently used elimination algorithm, Singleflight is a single flight, What is a single flight back to see the code again to understand it ~,testpb and GROUPCACHEPB like, PB End and protocol buffers can not escape the relationship. The rest of the root directory of the source file is definitely a variety of calls mentioned above a few packets, so here we first look at the top of the 5 folders (package) is what the content, sub-module break after the call logic to see the outer layer, the knowledge point is concatenated together.
What can we learn through Groupcache source reading?
Groupchace is significantly larger than cache2go knowledge, the source code contains at least the following knowledge points, we can advance Google some of these knowledge points, such as what RPC is, Golang how to use rpc;protobuf how to use, ring Hash (consistent hash) algorithm principle, LRU algorithm principle, singleflight is a programming skill, read the source we come to experience the beauty of it.
Rpc
Protobuf
Ring Hash
Lru
Singleflight
OK, let's talk about this here today, let's take a look at the consistency hashing algorithm and see how the ring hash is implemented in Groupcache.
148 Reads