Skip to content

xpzouying/groupcache-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

groupcache-practice

The practice for groupcache

Create the project use groupcache

Environments:

  • based on custom slow database for test
  • multiple cache nodes for HA

groupcache version

  • Date: 2020-02-24
  • Commit ID: 8c9f03a8e57eb486e42badaed3fb287da51807ba

Run step:

  1. run database server
cd database && go run main.go
  1. insert data into database
# insert one entry:
# key: name, value: zouying
curl -H "Content-Type: application/json" -X POST -d '{"key": "name", "value": "zouying"}' http://localhost:9000/set

# check insert
curl -H "Content-Type: application/json" -X POST -d '{"key": "name"}' http://localhost:9000/get
  1. run frontend (include cache). Two node in cache cluster.
cd frontend

# run the first node
go run ./main.go -addr=":8001" -port ":18001"

# run the second node
go run ./main.go -addr=":8002" -port ":18002"
  1. get the value, the first try will get from database
# try the first node api
curl -H "Content-Type: application/json" -X POST -d '{"key": "name"}' http://localhost:18001/get

# try the second node api
curl -H "Content-Type: application/json" -X POST -d '{"key": "name"}' http://localhost:18002/get

Releases

No releases published

Packages

No packages published

Languages