Skip to content

Instantly share code, notes, and snippets.

@binarytemple
Created July 4, 2014 14:46
Show Gist options
  • Select an option

  • Save binarytemple/31056495f96ea73cae41 to your computer and use it in GitHub Desktop.

Select an option

Save binarytemple/31056495f96ea73cae41 to your computer and use it in GitHub Desktop.

Riak local client

Riak local client is what you want to read from or write to Riak while running riak attach, and Erlang MapReduce job, or a post_commit hook.

Examples of using Riak local client

11: {ok,Client} = riak:local_client()
-> {ok,{riak_client,['dev1@127.0.0.1',undefined]}}

12: riak_client:list_buckets(Client)
-> {ok,[<<"test5">>,<<"testr52">>,<<"test2">>,<<"test1">>]}

13: riak_object:new(<<"groceries">>, <<"mine">>, <<"eggs & bacon">>)
-> {r_object,<<"groceries">>,<<"mine">>,
             [{r_content,{dict,0,16,16,8,80,48,
                               {[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                               {{[],[],[],[],[],[],[],[],[],[],[],[],...}}},
                         <<"eggs & bacon">>}],
             [],
             {dict,1,16,16,8,80,48,
                   {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                   {{[],[],[],[],[],[],[],[],[],[],[],[],[],...}}},
             undefined}
                                                                        
24: riak_client:put(O, Client)
-> ok


28: riak_client:get(<<"groceries">>, <<"mine">>, Client)
-> {ok,{r_object,<<"groceries">>,<<"mine">>,
                 [{r_content,{dict,3,16,16,8,80,48,
                                   {[],[],[],[],[],[],[],[],[],[],[],[],...},
                                   {{[],[],[],[],[],[],[],[],[],[],...}}},
                             <<"eggs & bacon">>}],
                 [{<<157,62,8,202,83,177,50,174>>,{1,63571692235}}],
                 {dict,1,16,16,8,80,48,
                       {[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                       {{[],[],[],[],[],[],[],[],[],[],[],...}}},
                 undefined}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment