a little riak book 的无聊总结 pre name=code class=python#!/bin/bash# riak http interface stays true to their intent: 1xx informational, 2xx success,# 3xx further action, 4xx client error, 5xx server error### putport=10018url=http://localhos
a little riak book 的无聊总结
#!/bin/bash# riak http interface stays true to their intent: 1xx informational, 2xx success,# 3xx further action, 4xx client error, 5xx server error### putport=10018url=http://localhost:$port/riakcase $1 in -1 ) echo nothing ;; ## put 1 ) curl -v -x put $curl/food/favorite \ -h 'content-type: text/plain' \ -d 'pizza' ;; ## get 2 ) curl -i -v -x get $url/food/favorite ;; ## post --> with post a key is optional, all it require is a bucket name , and ## it will generate a key you 3 ) curl -i -x post $url/people \ -h 'content-type: application/json' \ -d '{name: aaron}' ;; ## for any kind of write, you can add the returnbody=true parameter to force a value return, ## 和值相关的头, 如x-riak-vclock, eta这些都会被返回. ## post 也支持returnbody, get 会自动返回body,body才是内容,okey 4 ) curl -i -x post $url/people \ -h 'content-type: application/json' \ -d '{name: billy}' ;; ## delete: ## 1 . 删除一个已经被删除的对象在riak中会被表示为deleted,可以打一个 tombstone 标签。然后, ## 一个死神进程会被调用,这个进程会以后台的方式清理掉这些marked objs(可能的话,死神进程因该 ## 关掉), ## 2. 有两点需注意: ## a) 在riak中,删除的操作与属于一个写的操作,在计算读写比率时候,也因该这样考虑 ## b) 检查一个存在的key并不能说明他对应的对象是否存在,因为你可能读到的key可能是在'删除和 ## 备份的期间',所以你必须要读到 tombstones为止,才能说明一个key已被删除了 5 ) curl -i -x post $url/people/test \ -h 'content-type: application/json' \ -d '{name: billy}' echo ========== curl -i $url/people/test?returnbody=true echo ----------- curl -i -x delete $url/people/test ;; ## lists -> riak有两种不同lists,第一种列出集群中的所有buckets,第二种会根据指定的buckets列出所有的key,调用的方式相似,都是传入两个参数 6 ) curl -i $url?buckets=true echo echo =================== curl -i $url/food?keys=true echo echo ------------------- ;; ## lists 也可以流的方式传输 7 ) curl -v $url/food?list=stream ;;esac