cache/

directory
v0.0.0-...-bc5e729 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2017 License: MPL-2.0

README

cache

Based-on github.com/golang/groupcache, simple HTTP master and nodes system.

Example

import (
  "github.com/Focinfi/oncekv/cache/master"
  "github.com/Focinfi/oncekv/cache/ndoe"
)

// create a master
masterAddr := ":5550"
master := master.New(masterAddr)

// create three nodes with HTTP server addr, groupcache server addr and the masterAddr
node1 := node.New(":5551", ":5541", masterAddr) 
node1 := node.New(":5552", ":5542", masterAddr) 
node1 := node.New(":5553", ":5543", masterAddr) 

// Run the master and the three nodes separately
master.Start()
node1.Start()
node2.Start()
node3.Start()

How the master and nodes keep in touch?

  1. Master

    1. Serve POST /join for the new node
    2. Refresh the upderlying raft cluster address list
    3. Send POST /meta to all known nodes to keep heartbeat
  2. Node

    1. Serve GET /key/:key, delegate to groupcache.
    2. If one node should serve some pairs of key/value but has no caches, it will get the data from raft cluster.
    3. Serve POST /meta from master to update the peers list.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL