Skip to content

Instantly share code, notes, and snippets.

@blinkov
Created November 12, 2012 20:34
Show Gist options
  • Save blinkov/4061705 to your computer and use it in GitHub Desktop.
Save blinkov/4061705 to your computer and use it in GitHub Desktop.
Riak Increment Example
-module(riak).
-author("Ivan Blinkov <[email protected]>").
-export([incr/2]).
-define(COUNTERS_BUCKET,<<"counters">>).
incr(Pid, Key) ->
{ok, Object} = riakc_pb_socket:put(Pid,
riakc_obj:new(?COUNTERS_BUCKET, Key, <<>>),
[return_body]),
lists:sum([N || {_,{N,_}} <- binary_to_term(zlib:unzip(riakc_obj:vclock(Object)))]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment