Skip to content

Instantly share code, notes, and snippets.

@binarytemple
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

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

Select an option

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

Example of using Riak local client to PUT

Creating the Object

21: O = riak_object:new(<<"bucketfoo">>,
                        <<"bar">>,
                        "baz",
                        dict:from_list([{<<"content-type">>,
                                         "text/plain"}]))
-> {r_object,<<"bucketfoo">>,<<"bar">>,
             [{r_content,{dict,1,16,16,8,80,48,
                               {[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                               {{[],[],[],[],[],[],[],[],[],[],[[...]],[],...}}},
                         "baz"}],
             [],
             {dict,1,16,16,8,80,48,
                   {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                   {{[],[],[],[],[],[],[],[],[],[],[[<<...>>|...]],[],[],...}}},
             undefined}

Creating an instance of local client

22: {ok,C} = riak:local_client()
-> {ok,{riak_client,['riak@10.42.0.6',undefined]}}

PUT'ing the data into Riak

23: C:put(O)
-> ok
ok

GET'ing the data from Riak

24:  C:get(<<"bucketfoo">>,<<"bar">>).
{ok,{r_object,<<"bucketfoo">>,<<"bar">>,
              [{r_content,{dict,4,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],...},
                                {{[],[],[],[],[],[],[],[],[],[],...}}},
                          "baz"}],
              [{<<213,131,199,167,84,19,35,47>>,{1,63577762836}}],
              {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