Groupcache Source Parsing-Overview

Source: Internet
Author: User

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.

    1. Rpc

    2. Protobuf

    3. Ring Hash

    4. Lru

    5. 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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.