Created
November 12, 2012 20:34
-
-
Save blinkov/4061705 to your computer and use it in GitHub Desktop.
Riak Increment Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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