標籤:class blog code http ext get
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://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=trueecho ""echo "==================="curl -i $url/food?keys=trueecho ""echo "-------------------";; ## Lists 也可以流的方式傳輸7)curl -v $url/food?list=stream;;esac