A simple demo of buck cache server
A simple demo of buck cache server
This is a simple script to run a Buck cache server which trying to confirm binary HTTP protocol of Buck’s HTTP Cache API.
This simple python script referred Uber’s Buck cache server code to understand how exactly to parse GET
and PUT
requests.
I don’t want to handle those Java things so I decided just to write a simple python script to run a simple server for demo.
$ python3 ./simple-buck-cache-server.py <port-number> <cache-dir>
For example:
$ python3 ./simple-buck-cache-server.py 9527 ./buck-cache
Then this script will listen to port 9527
and read, write data to dir buck-cache
. If cache dir doesn’t exist, this script create it for you.
.buckconfig
If you want to use buck cache server, simply add it to your .buckconfig
:
[cache]
mode = http
http_url = http://simple.buck.cache.server:9527
cache_mode = readwrite
This script simply implemented handlers for 2 requests below:
/artifacts/key/{key}
Try to find {key}.buckcache
in <cache-dir>
, if found, just return the file with HTTP code 200
, otherwise return 404
.
/artifacts/key
The struct of request is:
Because this is just a demo, here just simply store data to {key}.buckcache
to <cache-dir>
.